///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>
///////////////////////////////
#include <acknex.h>
#define PRAGMA_PATH "./3D-models";
#define PRAGMA_PATH "./Graphics";
#define PRAGMA_PATH "./Sounds & fx";
#define PRAGMA_PATH "./Scripts";
#define PRAGMA_PATH "./Wads";
#include "easyshoot.c"
#include "movement.c"
var character_type = 1; // showing the first character model at game start
BMAP* arrowleft_pcx = "arrowleft.pcx";
BMAP* arrowright_pcx = "arrowright.pcx";
BMAP* pointer_tga = "pointer.tga";
BMAP* go_pcx = "go.pcx";
BMAP* play_play = "play.pcx";
STRING* tinylevel_wmb = "test.wmb";
ENTITY* character;
function character_left();
function character_right();
function set_current_character();
PANEL* play_pan =
{
bmap = "play.pcx";
pos_x = 0;
pos_y = 0;
layer = 50;
}
PANEL* leftclick_pan =
{
bmap = "arrowleft.pcx";
pos_x = 0;
pos_y = 0;
layer = 15;
on_click = character_left;
flags = SHOW | OVERLAY;
}
PANEL* rightclick_pan =
{
bmap = "arrowright.pcx";
pos_x = 250;
pos_y = 0;
layer = 15;
on_click = character_right;
flags = SHOW | OVERLAY;
}
PANEL* go_pan =
{
bmap = "go.pcx";
pos_x = 550;
pos_y = 0;
layer = 15;
on_click = go_play;
flags = SHOW | OVERLAY;
}
ENTITY* ent_sky;
void sky1(){
ent_morph(ent_sky, "spacecube1+6.bmp");
}
void sky2(){
ent_morph(ent_sky, "spacecube2+6.bmp");
}
function mouse_startup()
{
mouse_mode = 2;
mouse_map = pointer_tga;
while (1)
{
vec_set(mouse_pos, mouse_cursor);
wait(1);
}
}
function character_left()
{
character_type -= 1;
character_type = maxv(1, character_type);
set_current_character();
media_play("ploing.wav",NULL,100);
}
function character_right()
{
character_type += 1;
character_type = minv(6, character_type);
set_current_character();
media_play("ploing.wav",NULL,100);
}
function set_current_character()
{
if(character_type == 1)
ent_morph(character, "character1.mdl");
if(character_type == 2)
ent_morph(character, "character2.mdl");
if(character_type == 3)
ent_morph(character, "character3.mdl");
if(character_type == 4)
ent_morph(character, "character4.mdl");
if(character_type == 5)
ent_morph(character, "character5.mdl");
if(character_type == 6)
ent_morph(character, "character6.mdl");
// add as many characters as you want here
}
// attach this action to the character1.mdl model (the default character)
action my_character()
{
character = my;
while (1)
{
my.pan += 3 * time_step;
wait (1);
}
}
function go_play()
{
media_play("haleluja.wav",NULL,100);
media_play("ploing.wav",NULL,100);
set(play_pan, SHOW);
wait(-2);
mouse_mode = 0;
reset(leftclick_pan, SHOW);
reset(rightclick_pan, SHOW);
reset(go_pan, SHOW);
//set(race_pan, SHOW);
wait(-3);
level_load("play.WMB");
ent_sky = ent_createlayer("spacecube1+6.bmp", SKY | CUBE, 1);
reset(play_pan, SHOW);
}
action player_action()
{
if(character_type == 1)
ent_morph(me, "character1.mdl");
if(character_type == 2)
ent_morph(me, "character2.mdl");
if(character_type == 3)
ent_morph(me, "character3.mdl");
if(character_type == 4)
ent_morph(me, "character4.mdl");
if(character_type == 5)
ent_morph(me, "character5.mdl");
if(character_type == 6)
ent_morph(me, "character6.mdl");
player_pacman(); //make me a player [you may want to change this?]
}
code of easyshoot.c in Scripts folder
//////////////////////////////
// //
// Marian Frische //
// //
//////////////////////////////
// Includes //
#include <acknex.h>
// Defines //
#define HITOBJECT skill1
#define BULLETSPEED skill2
#define CREATORPARAENT skill3
#define BULLETFLAG skill4
// Functions //
function trail_effect_event(PARTICLE *p)
{
p.alpha -= 3*time_step;
if(p.alpha > 0)
p.lifespan = 4;
else
p.lifespan = 0;
}
function effect_particle_trail(PARTICLE *p)
{
p.size = 3;
vec_fill(p.blue, 128);
set(p, TRANSLUCENT|BRIGHT|BEAM);
p.lifespan = 99;
p.alpha = 50;
p.event = trail_effect_event;
}
function particle_trail(VECTOR* vec, VECTOR* vec2)
{
VECTOR vel;
vec_diff(vel, vec, vec2);
effect(effect_particle_trail, 1, vec, vel);
}
function effect_bullet_explosion(PARTICLE *p)
{
p.size = 2;
vec_set(p.blue, vector(random(255),random(255),random(255)));
set(p, TRANSLUCENT|BRIGHT|MOVE);
p.vel_x += random(1)-0.5;
p.vel_y += random(1)-0.5;
p.vel_z += random(1)-0.5;
vec_scale(p.vel_x, 2);
p.lifespan = 99;
p.alpha = 50;
p.event = trail_effect_event;
}
function destroy_bullet()
{
me.HITOBJECT = 1; //I got hit, destroy me.
effect(effect_bullet_explosion, 100, my.x, normal);
media_play("explosion.wav",NULL,40);
}
function act_bullet()
{
my.event = destroy_bullet; //enable the event, whenever it hits something or something hits it
my.emask |= (ENABLE_ENTITY|ENABLE_IMPACT|ENABLE_BLOCK);
my.HITOBJECT = 0; //init
VECTOR lastPos;
vec_set(lastPos, my.x);
while(!my.HITOBJECT) //as long as we are not yet hit
{
you = my.CREATORPARAENT; //you are my parent
c_move(me, vector(my.skill2*time_step,0,0), nullvector, GLIDE|IGNORE_YOU); //move
particle_trail(my.x, lastPos.x);
vec_set(lastPos.x, my.x);
wait(1);
}
ptr_remove(me); //remove me
}
function shoot_bullet(ENTITY* ent, var vertex, var bullet_speed)
{
if(ent_status(ent, 0) < vertex) //check for error [better of the user]
{
error("Vertex does not exist!"); //print error
return;
}
VECTOR temp;
vec_for_vertex(temp, ent, vertex); //get the position of the vertex
you = ent_create("star.mdl", temp, act_bullet); //create the bullet there
you.BULLETSPEED = bullet_speed; //set the bullet speed,
you.push = ent.push-1; //the push value,
vec_set(you.pan, ent.pan); //the pan,
you.CREATORPARAENT = ent; //and the set the parent as the given ent. [we do not want to hit ourselves]
you.BULLETFLAG = 111;
}
code of movement.c in scripts folder
//////////////////////////////
// //
// Marian Frische //
// //
//////////////////////////////
// Includes //
#include <acknex.h>
#define PRAGMA_PATH "./3D-models";
#define PRAGMA_PATH "./Graphics";
#define PRAGMA_PATH "./Sounds & fx";
#define PRAGMA_PATH "./Scripts";
#define PRAGMA_PATH "./Wads";
// Defines //
#define RotateSpeed skill1
#define FlySpeed skill1
#define MoveSpeed skill1
#define PanSpeed skill2
#define TileSize skill3
#define TiltSpeed skill3
#define SmoothSpeed skill4
#define SmoothToPan skill5
#define SmoothToTilt skill6
#define EnableCollision FLAG1
#define SmoothTransition FLAG1
#define SmoothAngles FLAG1
#define EnableGlide FLAG2
#define IgnorePush FLAG3
// Actions //
// help: Add this function to a entity you want to use as a rotating player.
// id: 10000
// uses: EnableCollision, EnableGlide, IgnorePush, RotateSpeed
action player_rotate()
{
player = me; //I am the player
if(is(my,FLAG1)) //Want to use collision?
{
wait(1);
c_setminmax(me); //set my bouding box
}
var collisionMode = 0; //the collision mode if flags are set
if(is(my, FLAG2)) //if the user wants to use the glide flag, add it to the collisionMode parameter
{
collisionMode = GLIDE;
}
if(is(my, FLAG3)) //if the user wants to use the push flag, add it to the collisionMode parameter
{
collisionMode += IGNORE_PUSH;
}
while(me) //as long as I am not destroyed
{
if(is(my,FLAG1)) //Collision?
{
//Calculate the result rotation speed by multiplying the rotateSpeed with the direction [-1, 0, 1] and time_step
c_rotate(me, vector((key_cul-key_cur)*my.RotateSpeed*time_step, 0, 0), collisionMode); //use collision based rotation
}
else
{
//Calculate the result rotation speed by multiplying the rotateSpeed with the direction [-1, 0, 1] and time_step
my.pan += (key_cul-key_cur)*my.RotateSpeed*time_step; //use direct turning
}
wait(1);
}
}
// help: Add this function to a entity you want to use as a flying player.
// id: 10001
// uses: EnableGlide, PanSpeed, TiltSpeed, SmoothSpeed, SmoothToPan, SmoothToTilt, IgnorePush, FlySpeed
action player_flymovement()
{
player = me; //I am the player
wait(1);
c_setminmax(me); //set my bouding box
var collisionMode = 0; //the collision mode if flags are set
if(is(my, FLAG2)) //if the user wants to use the glide flag, add it to the collisionMode parameter
{
collisionMode = GLIDE;
}
if(is(my, FLAG3)) //if the user wants to use the push flag, add it to the collisionMode parameter
{
collisionMode += IGNORE_PUSH;
}
while(me) //as long as I am not destroyed
{
c_move(me, vector(my.FlySpeed*time_step, 0, 0), nullvector, collisionMode); //Move forward with the desired speed
my.pan += (key_cul-key_cur)*my.PanSpeed*time_step; //rotate with the given speed [pan]
my.tilt += (key_cuu-key_cud)*my.TiltSpeed*time_step; //rotate with the given speed [tilt]
if(is(my, SmoothAngles)) //we want to smooth angles to 0?
{
if((key_cuu-key_cud) == 0) //up/down
{
my.tilt = ((1 - (my.SmoothSpeed/10)*time_step) * (my.tilt-my.SmoothToTilt)) + my.SmoothToTilt; //will smooth the tilt value to the given smoothto value
my.tilt = cycle(my.tilt, -90, 90);
}
if((key_cul-key_cur) == 0) //left/right
{
my.pan = ((1 - (my.SmoothSpeed/10)*time_step) * (my.pan-my.SmoothToPan)) + my.SmoothToPan; //will smooth the pan value to the given smoothto value
my.pan = cycle(my.pan, 0, 360);
}
}
my.tilt = cycle(my.tilt, -90, 90);
my.pan = cycle(my.pan, 0, 360);
wait(1);
}
}
// help: Add this function to a entity you want to use as a pacman like player.
// id: 10000
// uses: EnableCollision, EnableGlide, IgnorePush, PanSpeed, SmoothTransition, TileSize, MoveSpeed
action player_pacman()
{
player = me; //I am the player
wait(1);
c_setminmax(me); //set my bouding box
vec_scale(my.min_x, 0.9); //make the bouding box a bit smaller
vec_scale(my.max_x, 0.9);
var collisionMode = 0; //the collision mode if flags are set
var toPan = 0; //the new angle for the player
VECTOR temp; //temp vector
if(is(my, FLAG2)) //if the user wants to use the glide flag, add it to the collisionMode parameter
{
collisionMode = GLIDE;
}
if(is(my, FLAG3)) //if the user wants to use the push flag, add it to the collisionMode parameter
{
collisionMode += IGNORE_PUSH;
}
while(key_any) wait(1);
while(me) //as long as I am not destroyed
{
if((key_cul+key_cur+key_cuu+key_cud) == 1) //Only one key pressed
{
if(key_cuu) //set the new direction (in degrees)
toPan = 90;
if(key_cur)
toPan = 0;
if(key_cud)
toPan = 270;
if(key_cul)
toPan = 180;
vec_set(temp, vector(my.TileSize, 0 , 0)); //calculate the new position
vec_rotate(temp, vector(toPan, 0, 0));
vec_add(temp, my.x);
if(!c_trace(my.x, temp, IGNORE_PASSABLE|USE_BOX|IGNORE_ME)) //check if there is something in the way
{
if(is(my, FLAG1)) //for smooth turning
{
if(abs(toPan-my.pan) > abs(ang(toPan) - ang(my.pan))) //check if -180..180 is less way than 0..360
{
toPan = ang(toPan);
my.pan = ang(my.pan);
}
while(abs(toPan-my.pan) > my.PanSpeed * time_step) //rotate to the new angle
{
DEBUG_VAR(abs(toPan-my.pan),0);
if(toPan > my.pan)
{
my.pan += my.PanSpeed * time_step;
}
else
{
my.pan -= my.PanSpeed * time_step;
}
wait(1);
}
}
my.pan = toPan; //make sure we have a X*90° pan
vec_set(temp, vector(my.TileSize, 0 , 0)); //calculate the new position
vec_rotate(temp, my.pan);
vec_add(temp, my.x);
while(vec_dist(temp, my.x) > my.MoveSpeed * time_step) //move to the new position
{
c_move(me, vector(my.MoveSpeed*time_step, 0, 0), nullvector, collisionMode);
ent_animate(me, "run", my.skill10, ANM_CYCLE); //animate me with my run animation
my.skill10 += 5*time_step;
wait(1);
}
}
if((key_cul+key_cur+key_cuu+key_cud) != 1) //No or more than one key pressed?
{
ent_animate(me, "idle", my.skill11, ANM_CYCLE); //animate me with my idle animation
my.skill11 += 5*time_step;
}
}
wait(1);
}
}