Дополнения для игр

CTAPu4OK

КтапичОК О_О
Старейшина
Репутация
160 / 541
Скрипт движения игрока...

Код:
var walk_speed[3]; //скорость игрока

var jump_height = 30;//высота прыжка
var jump_time = 1; //время прыжка, каждый раз во время прыжка уменьшается от 1 до -1
var jump_enable = 1;//запрещает прыжки когда персонаж в воздухе
var crouch_timer;//для замедленного движения камеры когда персонаж приседает или встает
action player_move
{
var movement_speed = 10;
player = my;
//my.invisible = on;
my.skill40 = 100;
while (my.skill40 > 0)
{
player.pan -= 7 * mouse_force.x * time;
camera.tilt += 7 * mouse_force.y * time;
camera.x = player.x;
camera.y = player.y;
camera.z = player.z + 50;
camera.pan = player.pan;

vec_set (temp.x, my.x);
walk_speed.x = movement_speed * (key_w - key_s) * time;
walk_speed.y = movement_speed * (key_a - key_d) * 0.6 * time;

player_gravity();//опускает игрока на землю
if (key_space == 1 && jump_enable == 1) 
{//если игрок не в воздухе и нажат пробел то прыгать
player_jump();
}

if (key_c == 1 && jump_enable == 1) 
{//если игрок не в воздухе и нажата кнопка С то приседать
if(crouch_timer > -20){crouch_timer -= 5*time;}
//else{c_updatehull(my,1);}//если будешь сюда запихивать анимацию приседающего персонажа то это откорректирует bounding box по кадру анимации где он сидит. (1 замени на номер кадра где он сидит) это чтоб он не стукался тем местом где раньше была голова =)
camera.z+=crouch_timer;
}
else
{//если игрок сидит а ненадо то вставать
if(crouch_timer < 0){crouch_timer += 5*time;camera.z+=crouch_timer;}
//else{c_updatehull(my,1);}//1 замени на кадр где персонаж стоит
}

c_move (my, walk_speed.x, nullvector, ignore_passable | glide);
wait (1); 
}
}

function player_gravity()
{
vec_set (temp, my.x);
temp.z -= 10000;
my.skill11 = c_trace (my.x, temp.x, ignore_me | ignore_passable | use_box);

if (my.skill11 > 5) //игрок в воздухе
{
walk_speed.z -= 2 * time;//опускать на землю
jump_enable = 0;//запретить прыжки
}
else 
{ 
walk_speed.z = 0; //игрок на земле
jump_time = 1;//разрешить прыжки после коротких прыжков
jump_enable = 1;
}
if (my.skill11 <= 1)//игрок ушел под землю
{
walk_speed.z += 6 * time;//выталкивать на поверхность
}
}

function player_jump()
{
while (jump_time > -1)
{
if (key_space == 0) //разные прыжки в зависимости от того сколько времени был нажат пробел
{
return;
}

walk_speed.z = jump_height * jump_time * time;//скорость движения вверх = высота прыжка * время прыжка
jump_time -= 0.1 * time;//время прыжка уменьшается от 1 до -1
wait (1);
}
while (key_space == 1) {wait (1);} //ждать пока кнопка не будет отпущена
jump_time = 1; //разрешить прыгать опять
}


Лук будет валяться на земле (или у продавца), можно взять и стрелять только надо сделать модель лука и стрелы

Код:
function init_bowarrow();
function get_bow();
function move_arrow();
function hurt_you();

var arrow_fired = 0;

string arrow_mdl = <arrow.mdl>;

entity bow_entity 
{
type = <bow.mdl>;
layer = 10;
view = camera;
x = 30;
y = 8;
z = -10;
}

action bow // attach this action to your bow & arrow model
{
my.enable_impact = me;
my.event = get_bow;
while (my != null) // rotates as long as it hasn't been picked up
{
my.pan += 3 * time;
wait (1);
}
}

function get_bow()
{
wait (1);
ent_remove (me);
bow_entity.frame = 2; // show the arrow
bow_entity.visible = on;
}

function init_bowarrow()
{
clip_size = 0; // show all the triangles for all the models
while (1)
{
if ((mouse_left == 1 || key_ctrl == 1) && bow_entity.frame < 7)
{
bow_entity.frame += 2 * time;
}
else
{
if (bow_entity.frame >= 7 && arrow_fired == 0) // we have to fire
{
while (mouse_left == 1 || key_ctrl == 1) {wait (1);} // disable autofire
vec_set (temp, player.pos);
temp.z += 20; // the arrow is fired 20 quants above player's origin
ent_create (arrow_mdl, temp, move_arrow);
arrow_fired = 1; // a single arrow 
}
else // the player isn't shooting
{
arrow_fired = 0; 
bow_entity.frame = 2;
}
}
wait (1);
}
}

function move_arrow()
{
wait (1);
my.enable_entity = on;
my.enable_block = on;
my.event = hurt_you;
my.passable = on;
my.pan = camera.pan;
my.tilt = camera.tilt;

my.skill12 = 50; // skill12, 13, 14 act like a var
my.skill13 = 0;
my.skill14 = 0;
my.skill12 *= time;
while (my.skill12 != 0) // moves until it hits something
{
if (vec_dist (my.x, player.x) < 100) {my.passable = on;}
// don't collide with the player
else {my.passable = off;}
ent_move (my.skill12, nullvector);
wait (1);
}
}

function hurt_you()
{
wait (1);
if (event_type == event_entity)
{
my.skill12 = 0; // stop moving
you._HEALTH -= 80; // damage = 80;
ent_remove (me);
}
if (event_type == event_block)
{
my.skill12 = 0; // stop the arrow
my.passable = on; // the arrow won't move from now on so it shouldn't stand in our way
}
}


камера для игр типа симс, диабло, фаллаут, или каких нибудь ртс
автор - Orange Brat, условия использования - фри
Скачать

пример выбора ближайших целей и движения к ним
автор - LunaticX, условия использования - фри
Скачать

уровень станции, куча симпатичных моделей поездов и несколько домиков.
автор - неизвестен, условия использования - неизвестно
Скачать

Пример использования bloom шейдера
автор - неизвестен, условия использования - неизвестно
Скачать
 
Blacksmith Store Setup


Код:
Function Main()

 

       Player = Actor()

       D = OpenDialog(Player, ContextActor(), "Fat Ivan's Magic Shop")

              DialogOutput(Player, D, "Welcome to my shop! And what may I do for you?", 255, 255, 255)

              Result = DialogInput(Player, D, "Magic skill increase (10 gp)", "Mana boost (2 gp)", "Healing spell (15 gp)", "Charm creature spell (5 gp)", "Speed! (5 gp)", "Trade", "Nothing, goodbye")

              If (Result == 1)

                     If (Gold(Player) > 9)

                           ChangeGold(Player, -10)

                           SetAttribute(Player, "Magic", Attribute(Player, "Magic") + 2)

                           DialogOutput(Player, D, "Attribute increased!", 255, 255, 255)

                           ScreenFlash(Player, 255, 255, 255, 255, 1000)

                     Else

                           DialogOutput(Player, D, "You do not have enough gold!", 255, 255, 255)

                     EndIf

              ElseIf (Result == 2)

                     If (Gold(Player) > 1)

                           CurrentLevel = Attribute(Player, "Mana")

                           If (CurrentLevel < MaxAttribute(Player, "Mana"))

                                  ChangeGold(Player, -2)

                                  SetAttribute(Player, "Mana", CurrentLevel + 1)

                                  DialogOutput(Player, D, "Mana restored!", 255, 255, 255)

                            Else

                                  DialogOutput(Player, D, "Your mana is already full...", 255, 255, 255)

                           EndIf

                     Else

                           DialogOutput(Player, D, "You do not have enough gold!", 255, 255, 255)

                     EndIf

              ElseIf (Result == 3)

                     If (Gold(Player) > 14)

                           If (Attribute(Player, "Magic") > 9)

                                  ChangeGold(Player, -15)

                                  AddAbility(Player, "Heal Self", 1)

                                  DialogOutput(Player, D, "Spell learned!", 255, 255, 255)

                           Else

                                  DialogOutput(Player, D, "Sorry, your magic skill is not high enough.", 255, 255, 255)

                            EndIf

                     Else

                           DialogOutput(Player, D, "You do not have enough gold!", 255, 255, 255)

                     EndIf

              ElseIf (Result == 4)

                     If (Gold(Player) > 4)

                           If (Attribute(Player, "Magic") > 4)

                                  ChangeGold(Player, -5)

                                  AddAbility(Player, "Charm Creature", 1)

                                  DialogOutput(Player, D, "Spell learned!", 255, 255, 255)

                           Else

                                  DialogOutput(Player, D, "Sorry, your magic skill is not high enough.", 255, 255, 255)

                           EndIf

                     Else

                           DialogOutput(Player, D, "You do not have enough gold!", 255, 255, 255)

                     EndIf

              ElseIf (Result == 5)

                     If (Gold(Player) > 4)

                           ChangeGold(Player, -5)

                           AddActorEffect(Player, "Speed!", "Speed", 15, 30, 131)

                           ScreenFlash(Player, 255, 50, 50, 255, 1000)

                           DialogOutput(Player, D, "Vrrrrooooom!", 255, 50, 50)

                     Else

                           DialogOutput(Player, D, "You do not have enough gold!", 255, 255, 255)

                     EndIf

              ElseIf (Result == 6)

                     OpenTrading(Player, ContextActor())

                     DialogOutput(Player, D, "Thanks for coming!", 255, 255, 255)

              ElseIf (Result == 7)

                     CloseDialog(Player, D)

                     Return()

              EndIf

              DialogInput(Player, D, "Goodbye...")

       CloseDialog(Player, D)

 

       Return()

 

End Function



Blacksmith Actor Setup
Код:
Function Main()

 

       GiveItem(Actor(), "Forge Hammer", 1)

       GiveItem(Actor(), "questionmark", 1)

       GiveItem(Actor(), "Razor Mace", 2)

       GiveItem(Actor(), "Leather Shirt", 1)

       GiveItem(Actor(), "Odd Mushroom", 4)

       GiveItem(Actor(), "Beer", 11)

       SetName(Actor(), "Thoreg")

       Return()

 

End Function



/Command Script


Код:
Function Wave()

 

       // Animate player

       AnimateActor(Actor(), "Wave", 0.2, 0)

 

       // Done

       Return()

 

End Function

 

// Example '/heal' command for GMs

Function Heal()

 

       Player = Actor()

 

       // Check player is a GM

       If (PlayerIsGM(Player))

              // Set health to maximum

              Max = MaxAttribute(Player, "Health")

              SetAttribute(Player, "Health", Max)

       EndIf

 

       // Done

       Return()

 

End Function



OpenDialog



Используем...
Код:
OpenDialog(Actor, ContextActor, Title, [Background])


Пример
Код:
Function Main()
            Player = Actor()
            D = OpenDialog(Player, ContextActor(), "Blacksmith")
                DialogOutput(Player, D, "Welcome to my shop! Which item do you require?", 255, 255, 255)
                Result = DialogInput(Player, D, "A mace (40 gold)", "Nothing")
                If (Result == 1)
                    GiveItem(Player, "Razor mace", 1)
                ElseIf (Result == 2)
                    DialogOutput(Player, D, "Right you are, bye then!", 255, 255, 255)
                    DialogInput(Player, D, "Bye")
                    CloseDialog(Player, D)
                    Return()
                EndIf
                DialogOutput(Player, D, "Thank you! Come back when you want something else...", 255, 255, 255)
                DialogInput(Player, D, "Bye")
            CloseDialog(Player, D)
            Return()
        End Function



Spawn

Используем...
Код:
Spawn(ActorID, ZoneName, X, Y, Z[, RightClickScript, DeathScript])

Пример
Код:
Function Main()
            // Spawn an elf merchant
            ID = ActorID("Elf", "Mage")
            Ac = Spawn(ID, "Town", -65, 5, -55, "Merchant")
            GiveItem(Ac, "Mage Staff", 1)
            Return()
        End Function


DialogInput​


Используем....
Код:
DialogInput(Actor, Dialog, Option1, [Option2, ..., Option12])

Пример:
Код:
Function Main()
            Player = Actor()
            D = OpenDialog(Player, ContextActor(), "Blacksmith")
                DialogOutput(Player, D, "Welcome to my shop! Which item do you require?", 255, 255, 255)
                Result = DialogInput(Player, D, "A mace (40 gold)", "Nothing")
                If (Result == 1)
                    GiveItem(Player, "Razor mace", 1)
                ElseIf (Result == 2)
                    DialogOutput(Player, D, "Right you are, bye then!", 255, 255, 255)
                    DialogInput(Player, D, "Bye")
                    CloseDialog(Player, D)
                    Return()
                EndIf
                DialogOutput(Player, D, "Thank you! Come back when you want something else...", 255, 255, 255)
                DialogInput(Player, D, "Bye")
            CloseDialog(Player, D)
            Return()
        End Function

PlaySound​

Используем....
Код:
PlaySound(Actor, SoundID, Global)

Пример
Код:
Function Main()
            PlaySound(Actor(), 11, 1)
            Return()
        End Function


NewQuest

Используем....
Код:
NewQuest(Actor, Name, Status, StatusRed, StatusGreen, StatusBlue)

Пример
Код:
    Function Main()
            // Add a quest to the player's log
            NewQuest(Actor(), "The Flour Shipment", "Find 10 bags of flour!", 255, 255, 255)
            Return()
        End Function



Hour

Используем....
Код:
Hour()

Пример
Код:
Function Main()
            Time = Hour() $+ ":" $+ Minute()
            Output(Actor(), Time) // Displays the current game time
            Return()
        End Function
 
Сверху