|
Multiplayer Source von Locoweed in Lite-C Problem
#210274
06/09/08 14:29
06/09/08 14:29
|
Joined: Mar 2008
Posts: 68 Germany, Essen
virtualmarctek
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2008
Posts: 68
Germany, Essen
|
[DE]Ich habe das Multiplayer Source in Lite-C von Locoweed mal umgeschrieben, dass man keine Waffen hat. Es gibt keine Fehlermeldungen, der Server funktioniert auch aber der Client wird nach auswahl des Süielers beendet! [EN]I changed the Multiplayer SOurce in Lite-C from Locoweed so, that there are no weapons. I don't get any error and the server works fine. But the client is exiting after the Profession selecting! Hier der Code/Here the Code:
// Included files
#include <acknex.h>
#include <default.c>
//--------------------------------------------------------------------
// PATHS
//--------------------------------------------------------------------
// resources
#define PRAGMA_PATH ".\\Wads"
#define PRAGMA_PATH ".\\Sounds"
#define PRAGMA_PATH ".\\Models"
#define PRAGMA_PATH ".\\Entities"
#define PRAGMA_PATH ".\\Bitmaps"
//--------------------------------------------------------------------
// DEFINES
//--------------------------------------------------------------------
// Boolean
#define FALSE 0
#define TRUE 1
#define MAX_CONNECTIONS 8 // maximum number of people who can be connected to server
// Profession Types
#define PROF_MAN 1 // Nuclear scientist
#define PROF_WOMAN 2 // Biological scientist
// Profession speeds
#define PROF_MAN_SPEED 12 // Speed of nuclear scientist
#define PROF_WOMAN_SPEED 10 // Speed of biological scientist
// Profession's max health
#define PROF_MAN_MAX_HP 100
#define PROF_WOMAN_MAX_HP 100
// Profession's Armor Classes
// if player is hit by projectile, roll 20 sided die, if d20 >= AC, do damage
#define PROF_MAN_AC 6
#define PROF_WOMAN_AC 6
// Movement #defines
// Loco Changed 01/11/08
#define PLAYER_SPEED_TURN 8 // how fast a player rotates
// End Changed
// Animation States
#define ANIMATION_STATE_STAND 0
#define ANIMATION_STATE_WALK 1
#define ANIMATION_STATE_RUN 2
#define ANIMATION_STATE_ATTACK 3
// Animation Speeds
#define PLAYER_ANIM_WALK_SPEED 6 // animation speed for walk
#define PLAYER_ANIM_RUN_SPEED 8 // animation speed for run
#define PLAYER_ANIM_BLEND_SPEED 10 // speed for blend
// Player's grace time in frames (cannot be hit upon creation)
#define PLAYER_GRACE_TIME 100
//--------------------------------------------------------------------
// SKILL DEFINITIONS
//--------------------------------------------------------------------
#define player_number skill1 // player number this entity owned by
#define lunar_psychosis_rating skill2 // score
#define profession skill3 // entity's profession
#define speed skill4 // move speed
#define health skill5 // health
#define max_health skill6 // max health of entity
#define force_x skill8 // current forces for this ent
#define force_y skill9
#define force_z skill10
#define current_anim_percent skill11 // current animation percent
#define blend_anim_percent skill12 // blending animation percent
#define animation_state skill13 // animation state
#define prev_anim_state skill14 // previous animation state for blending
#define damage_die_1 skill18 // random damage of die 1
#define damage_die_2 skill19 // random damage of die2
#define grace_time skill23 // time left in ent's grace period
#define explosion_normal_x skill24 // normal vec used by projectile for effect
#define explosion_normal_y skill25
#define explosion_normal_z skill26
#define owned_by_hdl skill27 // owner of this ent (used for projectile)
//--------------------------------------------------------------------
// PROTOTYPES
//--------------------------------------------------------------------
function spawn_power_ups();
function check_server_disconnect();
function init_display();
function display_info();
function mouse_on();
function mouse_off();
function create_player();
function move_camera();
function input_scan();
function init_chat();
function local_effect();
function move_player();
function server_called();
function client_called();
function chat_entry();
function save_screen();
//--------------------------------------------------------------------
// RESOURCES
//--------------------------------------------------------------------
// Levels
STRING* world_str = "multiplayer.wmb"; // level string
//Models
STRING* str_woman = "cbabe.mdl"; // woman Model
STRING* str_man = "blue_warlock.mdl"; // man Model
// Fonts
FONT* fnt_century12 = "Centur12.pcx"; // Century12 font
// Bmaps
BMAP* pcxArrow = "arrow.pcx"; // pointer arrow
BMAP* bmpMan = "man.bmp"; // man panel
BMAP* bmpWoman = "woman.bmp"; // woman panel
BMAP* pcxTitle = "title.pcx"; // Title panel
BMAP* pcxSelect = "select.pcx"; // Selection panel
BMAP* pcxChat = "Chat.pcx"; // Chat Panel
BMAP* spark_map = "particle.pcx"; // bitmap used for sparks
//--------------------------------------------------------------------
// Variables
//--------------------------------------------------------------------
// Game Variables
var people_connected = 0; // number of people connected to server
var number_of_players = 0; // # of players in game
var profession_ID; // players profession ID
var temp_loc[3]; // temp vector
var vecFrom[3]; // temp vectors
var vecTo[3];
var profession_set = FALSE; // don't start game until profession set
var force[3]; // temp forces
var server_restart; // server died, server go back to profession selection
var client_restart; // client died, client go back to profession selection
var start_cam_pos[3]; // on death revert back to start cam position
var start_cam_pan[3];
var send_server_player; // tells server to send his player ent to all client
var effect_pos[3]; // position to do local effect
var effect_normal[3]; // normal for local explosion
var do_effect_type; // type of effect to do locally
var player_number_quit; // number of player who quit or was killed
//--------------------------------------------------------------------
// Strings
//--------------------------------------------------------------------
// display strings
STRING* str_people_connected = "#3"; // number of people connected to server
STRING* str_temp = "#100"; // temp STRING*
STRING* str_player_num = "#3"; // string to hold player number
STRING* str_number_of_players = "#3"; // string to hold number of players
STRING* str_player_name = "#32"; // player name for text display
STRING* str_latency = "#10";
STRING* str_bps = "#5";
// message strings
STRING* str_status_message = "#100"; // tells player game status, Loading & Grace Period
// Chat strings
STRING* strChat0 = "#100"; // Chat entries
STRING* strChat1 = "#100";
STRING* strChat2 = "#100";
STRING* strChat3 = "#100";
STRING* strChat4 = "#100";
STRING* strChat5 = "#100";
STRING* strChat6 = "#100";
STRING* strChat7 = "#100";
STRING* strChat8 = "#100";
STRING* strChatEntry = "#80"; // current chat entry
STRING* strSendChat = "#100"; // chat to send
//--------------------------------------------------------------------
// Entity Pointers
//--------------------------------------------------------------------
ENTITY* ptrTempEnt; // temp pointer to a entity
ENTITY* ptrOwner; // pointer to owner of an entity
ENTITY* ptrTempOwner; // temp pointer to owner of an entity
//--------------------------------------------------------------------
// Text
//--------------------------------------------------------------------
// text to display the number of people connected to game
TEXT* txt_people_connected =
{
pos_x = 0;
pos_y = 65;
layer = 15;
font fnt_century12;
string (str_people_connected);
}
// text to display this player's number
TEXT* txt_player_number =
{
pos_x = 0; // set in init_display
pos_y = 5;
layer = 15;
font fnt_century12;
string (str_player_num);
}
// text to display the number of players currently in game
TEXT* txt_number_of_players =
{
pos_x = 0; // set in init_display
pos_y = 35;
layer = 15;
font fnt_century12;
string (str_number_of_players);
}
// text for chat panel
TEXT* txtChat =
{
pos_x = 2;
pos_y = 0;
layer = 30;
font _a4font;
strings = 9;
string = (strChat0, strChat1, strChat2, strChat3, strChat4,
strChat5, strChat6, strChat7, strChat8);
}
// text for chat entry
TEXT* txtChatEntry =
{
pos_x = 2;
pos_y = 0;
layer = 30;
font _a4font;
string (strChatEntry);
}
// text to display this player's name
TEXT* txt_player_name =
{
pos_x = 5;
pos_y = 5;
layer = 15;
font fnt_century12;
string (str_player_name);
flags = visible;
}
// text that tells player game status
TEXT* txt_status_message =
{
pos_x = 0; // set in init_display
pos_y = 0; // set in init_display
layer = 15;
font fnt_century12;
string (str_status_message);
}
// text for latency
TEXT* txt_latency =
{
pos_x = 0; // set in init_display()
pos_y = 95;
layer = 15;
font fnt_century12;
string (str_latency);
}
// text for bytes per second
TEXT* txt_bps =
{
pos_x = 0; // set in init_display()
pos_y = 125;
layer = 15;
font fnt_century12;
string (str_bps);
}
//--------------------------------------------------------------------
// Panels
//--------------------------------------------------------------------
// Profession selection panels
PANEL* pnlMan =
{
bmap = bmpMan;
layer = 21;
pos_x = 0;
pos_y = 0;
on_click = set_prof_man;
flags = overlay, transparent;
}
PANEL* pnlWoman =
{
bmap = bmpWoman;
layer = 21;
pos_x = 0;
pos_y = 0;
on_click = set_prof_woman;
flags = overlay, transparent;
}
// panel title
PANEL* pnlTitle =
{
bmap = pcxTitle;
layer = 18;
pos_x = 0;
pos_y = 0;
flags = overlay,transparent;
}
// panel select
PANEL* pnlSelect =
{
bmap = pcxSelect;
layer = 18;
pos_x = 0;
pos_y = 0;
flags = overlay,transparent;
}
// chat panel
PANEL* pnlChat =
{
bmap = pcxChat;
layer = 18;
pos_x = 0;
pos_y = 0;
flags = overlay,transparent;
}
//--------------------------------------------------------------------
// MAIN
//--------------------------------------------------------------------
function main()
{
fps_max = 60; // lock fps at 60 for all players
fps_lock = ON;
dplay_smooth = 0; // dplay_smooth is causing too much overshoot and jerks
// The engine starts in the resolution given by the following vars.
video_mode = 7; // screen size 800x600
video_screen = 1; // start settings for Fullscreen
on_server = server_called; // on server event, call server_called()
on_client = client_called; // on client event, call cleint_called()
on_enter = chat_entry; // on <enter> start chat entry
on_p = save_screen; // on 'p' key save screenshot
randomize(); // set random seed
level_load(world_str); // load level
wait(-.5); // make sure level is loaded
// if not a single player game, wait for connection
#ifdef server
while(connection== 0) {wait(1);} // wait until level loaded and connection set
#endif
#ifdef client
while(connection== 0) {wait(1);} // wait until level loaded and connection set
#endif
vec_set(start_cam_pos,camera.x); // save camera's original poistion for death
vec_set(start_cam_pan,camera.pan);
wait(1);
// had to place check for power ups here incase server doesn't choose professiion
// until after clients choose theirs
// if host, count yourself as a connection
if (connection == 3)
{
people_connected = 1;
}
// while game not over / restart here after death
while(1)
{
vec_set(camera.x,start_cam_pos); // get original camera position
vec_set(camera.pan,start_cam_pan);
check_server_disconnect(); // continually checks is server is gone
// if dedicated server skip these
if (connection != 1)
{
init_display(); // initiliaze text positions as necessary
display_info(); // continually display any information we want to show
mouse_mode = 2; // mouse with no force changes
mouse_on(); // turn mouse on
// turn off all text not needed for profession selection
reset(txt_player_number,VISIBLE);
//display profession selection panels
set(pnlMan,VISIBLE);
set(pnlWoman,VISIBLE);
set(pnlTitle,VISIBLE);
set(pnlSelect,VISIBLE);
// if not single player mode, display multiplayer information
if(connection != 0)
{
set(txt_people_connected,VISIBLE);
set(txt_number_of_players,VISIBLE);
set(txt_player_number,VISIBLE);
set(txt_bps,VISIBLE);
set(txt_latency,VISIBLE);
}
// wait for a profession to be selected
while(!profession_set)
{
wait(1);
}
mouse_off(); // turn mouse off
// hide profession selection panels
reset(pnlMan,VISIBLE);
reset(pnlWoman,VISIBLE);
reset(pnlTitle,VISIBLE);
reset(pnlSelect,VISIBLE);
create_player(); // create player
move_camera(); // call simple 3rd Person chase camera
input_scan(); // get inputs
init_chat(); // intitialize chat variables
local_effect(); // continually check for effect to be run on client
// wait for this player's entity to be created
while(!player)
{
wait(1);
}
// display player specific text
set(txt_player_number,VISIBLE);
// display loading message
str_cpy(str_status_message, "Initializing Player...");
set(txt_status_message,VISIBLE);
// after player has a weapon we can continue to
// grace period message
wait(1);
str_cpy(str_status_message, "Grace Period Active");
}
// main game loop
while(profession_set == TRUE)
{
if(connection!=1) // if player is dead restart profession selection
{
profession_set = FALSE; // no profession until select again
}
//dedicated server skips this
if (connection != 1)
{
// if grace period over, hide message
if (player.grace_time == 0)
{
reset(txt_status_message,VISIBLE);
}
}
wait(1);
}
player = NULL; // set player to NULL until created again
wait(1);
}
}
function check_server_disconnect()
{
while(1)
{
// server disconnected so quit client too
if (dplay_latency == 0 && dplay_bps == 0 && connection == 2)
{
sys_exit(NULL);
}
wait(1);
}
}
// Desc: switches the mouse on
function mouse_on()
{
mouse_map = pcxArrow;
while(mouse_mode > 0)
{
vec_set(mouse_pos,mouse_cursor);
wait(1); // now move it over the screen
}
}
// Desc: switches the mouse off
function mouse_off()
{
mouse_mode = 0;
}
//--------------------------------------------------------------------
// Function Server_Called(): server was called
//--------------------------------------------------------------------
function server_called()
{
// if new player connected, increment people connected
// and tell him it's ok to continue
if ((event_type == EVENT_JOIN) && (people_connected < MAX_CONNECTIONS))
{
people_connected += 1; // another person connected
send_var(people_connected); // send number of people connected
}
// some one disconnected
if (event_type == EVENT_LEAVE)
{
people_connected -= 1; // one less person connected to server
send_var(people_connected); // send number of people connected
}
// chat stuff
if (event_type == EVENT_STRING)
{
if (!str_cmp(strSendChat,""))
{
send_string(strSendChat); // send string to clients
str_cpy(strChat0, strChat1); // move old chat entries up 1
str_cpy(strChat1, strChat2);
str_cpy(strChat2, strChat3);
str_cpy(strChat3, strChat4);
str_cpy(strChat4, strChat5);
str_cpy(strChat5, strChat6);
str_cpy(strChat6, strChat7);
str_cpy(strChat7, strChat8);
str_cpy(strChat8, strSendChat);
str_cpy(strSendChat,"");
}
}
}
//--------------------------------------------------------------------
// Function Client_Called(): client was called
//--------------------------------------------------------------------
function client_called()
{
// string event
if (event_type == EVENT_STRING)
{
// chat entry sent from server, process
if (!str_cmp(strSendChat,""))
{
str_cpy(strChat0, strChat1); // move old chat entries up 1
str_cpy(strChat1, strChat2);
str_cpy(strChat2, strChat3);
str_cpy(strChat3, strChat4);
str_cpy(strChat4, strChat5);
str_cpy(strChat5, strChat6);
str_cpy(strChat6, strChat7);
str_cpy(strChat7, strChat8);
str_cpy(strChat8, strSendChat);
str_cpy(strSendChat,"");
}
}
}
//--------------------------------------------------------------------
// PLAYER EVENTS
//--------------------------------------------------------------------
function player_events()
{
// client disconnected
if (event_type == EVENT_DISCONNECT)
{
number_of_players -= 1; // decrement number of players
// Go through all entities, any player# that was above mine, decrement his player number
you = ent_next(NULL);
while(you != NULL)
{
if(you.player_number > my.player_number)
{
you.player_number -= 1;
send_skill(you.player_number, SEND_ALL); // send new player#
}
you =ent_next(you);
}
send_var(number_of_players); // let everyone know new number of players
ent_remove(me); // remove ent of player that quit
}
}
//--------------------------------------------------------------------
// DISPLAY INFO - continuously displays game information
//--------------------------------------------------------------------
function display_info()
{
while(1)
{
str_cpy(str_player_name, "Player Name: ");
str_cat(str_player_name, player_name);
str_cpy(str_people_connected, "People Connected: ");
str_for_num(str_temp, people_connected);
str_cat(str_people_connected, str_temp);
str_cpy(str_number_of_players, "Number of Players: ");
str_for_num(str_temp, number_of_players);
str_cat(str_number_of_players, str_temp);
str_cpy(str_bps, "BPS: ");
str_for_num(str_temp, dplay_bps);
str_cat(str_bps, str_temp);
if (player != NULL) // player exist
{
str_cpy(str_player_num, "Player Number: ");
str_for_num(str_temp, player.player_number);
str_cat(str_player_num, str_temp);
}
wait(1);
}
}
//--------------------------------------------------------------------
// MOVE_OFFICER - action for operations officer
//--------------------------------------------------------------------
action move_man()
{
my.profession = PROF_MAN;
move_player();
}
//--------------------------------------------------------------------
// MOVE_NUCLEAR - action for nuclear scientist
//--------------------------------------------------------------------
action move_woman()
{
my.profession = PROF_WOMAN;
move_player();
}
//--------------------------------------------------------------------
// Function Animate(): animate a entity
//--------------------------------------------------------------------
function animate()
{
set(my, DYNAMIC); // let server know this entity is not static - do not remove
proc_mode = PROC_LATE; // make sure forces set before we run animation
// temporary code for what I think is a Bug in Server Mode A6.31
// you can remove this in later versions of 3DGS I believe
if(!my.x && !my.y && !my.z)
{
return;
}
while(my)
{
if (my.animation_state == ANIMATION_STATE_RUN)
{
my.current_anim_percent += PLAYER_ANIM_RUN_SPEED * time_step;
}
else
{
my.current_anim_percent += PLAYER_ANIM_WALK_SPEED * time_step;
}
if( my.current_anim_percent > 100 )
{
my.current_anim_percent -= 100;
}
// do animation of current animation state
if (my.animation_state == ANIMATION_STATE_WALK)
{
if(my.prev_anim_state != my.animation_state)
{
my.blend_anim_percent += PLAYER_ANIM_BLEND_SPEED * time_step;
my.blend_anim_percent = minv(my.blend_anim_percent,100);
ent_blend("walk",0,my.blend_anim_percent);
if(my.blend_anim_percent == 100)
{
my.current_anim_percent=0;
ent_animate(me,"walk",my.current_anim_percent,ANM_CYCLE );
my.prev_anim_state = my.animation_state;
my.blend_anim_percent = 0;
}
}
else
{
ent_animate( me, "walk", my.current_anim_percent, ANM_CYCLE);
}
}
else
{
if (my.animation_state == ANIMATION_STATE_STAND)
{
if(my.prev_anim_state != my.animation_state)
{
my.blend_anim_percent += PLAYER_ANIM_BLEND_SPEED * time_step;
my.blend_anim_percent = minv(my.blend_anim_percent,100);
ent_blend("stand",my.current_anim_percent,my.blend_anim_percent);
if(my.blend_anim_percent == 100)
{
my.current_anim_percent=0;
ent_animate(me,"stand",my.current_anim_percent,ANM_CYCLE );
my.prev_anim_state = my.animation_state;
my.blend_anim_percent = 0;
}
}
else
{
ent_animate( me, "stand", my.current_anim_percent, ANM_CYCLE );
}
}
else
{
if (my.animation_state == ANIMATION_STATE_RUN)
{
if(my.prev_anim_state != my.animation_state)
{
my.blend_anim_percent += PLAYER_ANIM_BLEND_SPEED * time_step;
my.blend_anim_percent = minv(my.blend_anim_percent,100);
ent_blend("run",my.current_anim_percent,my.blend_anim_percent);
if(my.blend_anim_percent == 100)
{
my.current_anim_percent=0;
ent_animate(me,"run",my.current_anim_percent,ANM_CYCLE );
my.prev_anim_state = my.animation_state;
my.blend_anim_percent = 0;
}
}
else
{
ent_animate( me, "run", my.current_anim_percent, ANM_CYCLE );
}
}
else // attack
{
if(my.prev_anim_state != my.animation_state)
{
my.blend_anim_percent += PLAYER_ANIM_BLEND_SPEED * time_step;
my.blend_anim_percent = minv(my.blend_anim_percent,100);
ent_blend("attack",my.current_anim_percent,my.blend_anim_percent);
if (my.blend_anim_percent == 100)
{
my.current_anim_percent=0;
ent_animate(me,"attack",my.current_anim_percent,ANM_CYCLE );
my.prev_anim_state = my.animation_state;
my.blend_anim_percent = 0;
}
}
else
{
ent_animate( me, "attack", my.current_anim_percent, ANM_CYCLE );
}
}
}
}
wait(1);
}
}
function NIX()
{
wait(0);
}
//--------------------------------------------------------------------
// LOCAL_ACTIVITIES_NUCLEAR - performs local ativities for Nuke Scientist
//--------------------------------------------------------------------
function local_activities_man()
{
you = my; // save MY into YOU because weapon_local() needs to know who owner is
// Attach correct weapon to player
ent_createlocal(str_man, my.x, NIX); // created emulator at
// player position locally
animate(); // do my animation locally
}
//--------------------------------------------------------------------
// LOCAL_ACTIVITIES_BIO - performs local ativities for Bio Scientist
//--------------------------------------------------------------------
function local_activities_woman()
{
you = my; // save MY into YOU because weapon_local() needs to know who owner is
// Attach correct weapon to player
ent_createlocal(str_woman, my.x, NIX); // created emulator at
// player position locally
animate(); // do my animation locally
}
//--------------------------------------------------------------------
// Function Two_Dice_damage - rolls 2 dice stored in skills
//--------------------------------------------------------------------
function two_dice_damage()
{
var random1 = 0; // random numbers
var random2 = 0;
var dam; // total damage
// Also, my.damage_die1 should always be a positive number
if ((my.damage_die_1 <= 0)&&(my.damage_die_2 <= 0)||(my.damage_die_1 <=0))
// The below commented code is better, but would be harder to understand
// it does the exact same thing as above though
// if ((my.damage_die_1 <= 0)||(my.damage_die_2 < 0))
{
return(0);
}
random1 = integer(random(my.damage_die_1)) + 1; // get roll die 1
// we will give the ability to have 1 die damage by setting my.damage_die_2
// to 0
if (my.damage_die_2 != 0)
{
random2 = integer(random(my.damage_die_2)) + 1; // get roll die 2
}
dam = random1 + random2; // get damage
return (dam); // return damage
}
//--------------------------------------------------------------------
// Function Vec_Randomize(): randomize a vector for explosion
//--------------------------------------------------------------------
function vec_randomize(var* vec,range)
{
vec[0] = random(1) - 0.5;
vec[1] = random(1) - 0.5;
vec[2] = random(1) - 0.5;
vec_normalize(vec, random(range));
}
//--------------------------------------------------------------------
// Function Part_Alphafade(): fade particle over time
//--------------------------------------------------------------------
function part_alphafade(PARTICLE *p)
{
p.alpha -= 2*time_step;
if (p.alpha <= 0) { p.lifespan = 0; }
}
//--------------------------------------------------------------------
// Function Effect_Explosion(): do an explosion
//--------------------------------------------------------------------
function effect_explosion(PARTICLE *p)
{
var temp_1[3]; // temp vector
vec_randomize(temp_1,10);
vec_add(p.vel_x, temp_1);
p.alpha = 15 + random(5);
p.bmap = spark_map;
set(p,BEAM|BRIGHT|MOVE);
p.event = part_alphafade;
}
//--------------------------------------------------------------------
// MOVE_PLAYER - Move the player
//--------------------------------------------------------------------
function move_player()
{
var trace_vecFrom[3];
var trace_vecTo[3];
my.emask |= ENABLE_DISCONNECT;
my.smask |= NOSEND_FRAME;
my.event = player_events; // player events function
set(my,POLYGON|TRANSLUCENT);
c_setminmax(my);
my.pan = random(360); // face random direction
my.alpha = 20;
my.grace_time = PLAYER_GRACE_TIME; // set time left in grace period
send_skill(my.grace_time,0);
// server gives new player's ent his player number
number_of_players += 1; // now that new player's entity has been &
// increment number_of_players
send_var(number_of_players); // send new number_of_players to all clients
my.player_number = number_of_players; // set the player_number skill
send_skill(my.player_number, SEND_ALL); // send player_number skill to all clients
// this code is to solve high latency creation problem
wait(-.3); // this can be left at .3 no matter what
ent_sendnow(my);
wait(-.3); // sleep(3); // high latency solution for now
// if not client connection
if(connection != 2)
{
if (my.profession == PROF_MAN)
{
my.speed = PROF_MAN_SPEED; // set player speed
my.health = PROF_MAN_MAX_HP; // set health
my.max_health = PROF_MAN_MAX_HP; // set max health
// send health, max-health
send_skill(my.health, SEND_VEC+SEND_ALL);
you = my; // save me as owner for weapon being created
// Attach correct weapon to player
ent_createlocal(str_man, my.x, NIX); // created rod at
// player position locally
proc_local(my,local_activities_man); // local animation and other activities
}
if (my.profession == PROF_WOMAN)
{
my.speed = PROF_WOMAN_SPEED; // set player speed
my.health = PROF_WOMAN_MAX_HP; // set health
my.max_health = PROF_WOMAN_MAX_HP; // set max health
// send health, max-health
send_skill(my.health, SEND_VEC+SEND_ALL);
you = my; // save me as owner for weapon being created
// Attach correct weapon to player
ent_createlocal(str_woman, my.x, NIX); // created emulator at
// player position locally
proc_local(my,local_activities_woman); // local animation and other activities
}
}
// if Host animate for Host or single player, dedicated server needs not animate for itself
if ((connection == 3) || (connection == 0))
{
animate(); // animate entity
}
while(my.health > 0) // while this entity is alive
{
// Resting code
// if standing
if ((my.force_x == 0)&&(my.force_y == 0))
{
my.health += .05*time_step; // add some health
if(my.health > my.max_health)
{
my.health = my.max_health;
}
}
// Exhaustion code
// if running
if(abs(my.force_x) > 1)
{
my.health -= .05*time_step; // subtract some health
if(my.health < 1) // don't let player run himself to death
{
my.health = 1;
}
}
// I am in grace period, amke sure everyone knows that and make me
// transparent until I can be hit
if(my.grace_time)
{
my.grace_time -= 1*time_step; // decrement grace time
// make player more visible
my.alpha = 20 + ((PLAYER_GRACE_TIME-my.grace_time)/PLAYER_GRACE_TIME)*50;
// Oops, grace period over
if(my.grace_time <= 0)
{
my.grace_time = 0;
reset(my,TRANSLUCENT);
send_skill(my.grace_time, 0); // make sure client that created ent knows
// grace period is over
}
}
my.prev_anim_state = my.animation_state; // save animation state
// intially set animation to walk, this will be changed below if necessary
my.animation_state = ANIMATION_STATE_WALK;
// if moving forward or backwards at walking rate, set animation to walk
if((abs(my.force_x) > 0) && (abs(my.force_x) <= 1))
{
my.animation_state = ANIMATION_STATE_WALK;
}
else
{
// if moving forward or backwards at run, set animation to run
if(abs(my.force_x) > 1)
{
my.animation_state = ANIMATION_STATE_RUN;
}
else
{
// if entity is not turning, then all that is left is standing
if (my.force_y == 0)
{
my.animation_state = ANIMATION_STATE_STAND;
}
}
}
// if animation state changed, send new animation state to all clients
// so they can do animation locally
if(my.animation_state != my.prev_anim_state)
{
send_skill(my.animation_state,SEND_ALL);
}
// get new pan
my.pan = my.force_y * PLAYER_SPEED_TURN * time_step + my.pan;
// use time & speed_forwards_factor
force[0] = my.force_x * my.speed * time_step;
force[1] = 0;
force[2] = 0;
//move_mode = glide + ignore_passable + ignore_passents + ignore_you;
move_mode = GLIDE|IGNORE_PASSABLE|IGNORE_PASSENTS|IGNORE_YOU;
c_move(my, force, nullvector,move_mode);
// scan for floor if we are moving
if (my.force_x || my.force_y || my.force_z)
{
//Scan floor
trace_mode = IGNORE_SPRITES|IGNORE_PASSENTS|IGNORE_PASSABLE|IGNORE_MODELS|USE_BOX;
vec_set(vecFrom,my.x);
vec_set(vecTo,my.x);
vecTo[2] -= 400;
result = c_trace(vecFrom,vecTo,trace_mode);
my.z = target.z + ((my.max_z - my.min_z)/2);//Set to the floor
}
wait(1);
}
number_of_players -= 1; // decrement number of players
player_number_quit = my.player_number; // save player number who was killed
// Go through all entities, any player# that was above mine, decrement his player number
you = ent_next(NULL);
while(you != NULL)
{
if(you.player_number > player_number_quit)
{
you.player_number -= 1;
send_skill(you.player_number, SEND_ALL); // send new player#
}
you =ent_next(you);
}
send_var(number_of_players); // let everyone know new number of players
send_skill(my.health,0); //send changed health to client owner
wait(3);
ent_remove(my); // remove ent of player that died
}
//--------------------------------------------------------------------
// MOVE CAMERA - Simple 3rd Person Chase camera
//--------------------------------------------------------------------
function move_camera()
{
var distance;
var adj_cam_tilt;
var camera_next[3];
// if died restart camera here
while(1)
{
// wait for player to be created
while (player == NULL)
{
wait (1);
}
while (player != NULL) // player exist?
{
camera_next[0] = player.x - cos (player.pan) * 200;
camera_next[1] = player.y - sin (player.pan) * 200;
camera_next[2] = player.z + 5;
you = player;
// make sure camera has unobstructed view
trace_mode = IGNORE_SPRITES|IGNORE_YOU|IGNORE_PASSABLE|USE_BOX;
distance = c_trace(player.x,camera_next,trace_mode);
if (distance)
{
distance -= 2;
camera.x = player.x - cos (player.pan) * distance;
camera.y = player.y - sin (player.pan) * distance;
}
else
{
camera.x = player.x - cos (player.pan) * 200;
camera.y = player.y - sin (player.pan) * 200;
}
camera.z = player.z + 75;
camera.pan = player.pan;
if(distance==0)
{
distance = 200;
}
// if players back close to wall, tilt camera down some so we can see
// player as long as possible and still be able to see
// play field
adj_cam_tilt = (100/distance);
if(adj_cam_tilt > 1.75)
{
adj_cam_tilt = 1.75;
}
camera.tilt = -10;
camera.tilt += (camera.tilt*adj_cam_tilt);
adj_cam_tilt = 0;
camera.roll = 0;
wait (1);
}
wait(1);
}
}
//--------------------------------------------------------------------
// CREATE PLAYER - create player at random location
//--------------------------------------------------------------------
function create_player()
{
var position_found = FALSE;
while (position_found == FALSE)
{
// get random start vector around center of level
vecFrom[0] =-400 + random(800);
vecFrom[1] =-400 + random(800);
vecFrom[2] = 200;
vec_set(vecTo,vecFrom);
vecTo[2] = -200;
trace_mode = IGNORE_SPRITES|IGNORE_PASSENTS|IGNORE_PASSABLE|IGNORE_MODELS|USE_BOX|SCAN_TEXTURE;
c_trace(vecFrom,vecTo,trace_mode);
// check for floor texture, if floor create entity
if((str_stri(tex_name,"earthtile") != FALSE)||(str_stri(tex_name,"crator") != FALSE))
{
vec_set(temp_loc,vecTo);
temp_loc[2] = target.z + 35;
// create player's entity depending on profession
if (profession_ID == PROF_MAN)
{
player = ent_create(str_man,temp_loc,move_man);
}
if (profession_ID == PROF_WOMAN)
{
player = ent_create(str_woman,temp_loc,move_woman);
}
position_found = TRUE; // found floor to create player on
}
}
}
//--------------------------------------------------------------------
// Function Set_Prof_MAN: Player chose man
//--------------------------------------------------------------------
function set_prof_man()
{
profession_ID = PROF_MAN;
profession_set = TRUE;
}
//--------------------------------------------------------------------
// Function Set_Prof_WOMAN: Player chose woman
//--------------------------------------------------------------------
function set_prof_woman()
{
profession_ID = PROF_WOMAN;
profession_set = TRUE;
}
//--------------------------------------------------------------------
// Function Init_Display: set-up text positions according to screen size
//--------------------------------------------------------------------
function init_display()
{
pnlTitle.pos_y = screen_size.y/2 + 100;
pnlTitle.pos_x = screen_size.x/2 - 150;
pnlTitle.alpha = 75;
pnlSelect.pos_y = screen_size.y/2 - 100;
pnlSelect.pos_x = screen_size.x/2 - 150;
pnlSelect.alpha = 75;
pnlMan.pos_y = screen_size.y/2;
pnlMan.pos_x = screen_size.x/2 - 300;
pnlMan.alpha = 75;
pnlWoman.pos_y = screen_size.y/2;
pnlWoman.pos_x = screen_size.x/2 - 75;
pnlWoman.alpha = 75;
txt_people_connected.pos_x = screen_size.x - 350;
txt_player_number.pos_x = screen_size.x - 350;
txt_number_of_players.pos_x = screen_size.x - 350;
txt_latency.pos_x = screen_size.x - 350;
txt_bps.pos_x = screen_size.x - 350;
txt_status_message.pos_x = screen_size.x/2 - 150;
txt_status_message.pos_y = screen_size.y/2;
}
function input_scan()
{
// only send changed skill values, so we need variable to store old values
var force_x_old;
var force_y_old;
while (1)
{
// if player has been created get inputs for him
if (player)
{
force_x_old = player.force_x; //store old force values
force_y_old = player.force_y;
player.force_x = 0; // set force to 0 until we get key input
player.force_y = 0;
// <w> or <cursur up> moves forward
if ((key_w == 1)||(key_cuu == 1))
{
player.force_x = 1;
}
// if moving mouse
if(mouse_force.x)
{
player.force_y = -mouse_force.x;
}
// <s> or <cursor left> moves back
if ((key_s == 1)||(key_cud == 1))
{
player.force_x = -1;
}
// <shift> for run
if (key_shift == 1)
{
player.force_x = player.force_x * 1.5; // run is 1.5 times faster than walk
}
// if any forces have changed, send new forces to server
if(player.force_x != force_x_old || player.force_y != force_y_old)
{
// if client, send forces to server, if we are single/host/server values need not
// be sent
if(connection == 2)
{
send_skill(player.force_x,SEND_VEC); // send force vec to server
}
}
}
wait(1);
}
}
//--------------------------------------------------------------------
// Init_Chat - Initializ chat panel
//--------------------------------------------------------------------
function init_chat()
{
// if host or client set up chat
if (connection == 2 || connection == 3)
{
pnlChat.pos_y = screen_size.y - 100;
txtChat.pos_y = screen_size.y - 100;
txtChatEntry.pos_y = screen_size.y - 15;
set(pnlChat,VISIBLE);
set(txtChat,VISIBLE);
reset(txtChatEntry,VISIBLE);
}
}
//--------------------------------------------------------------------
// Chat_Entry - get chat input from player
//--------------------------------------------------------------------
function chat_entry()
{
// if host or client
if (connection == 2 || connection == 3)
{
// if inkey already open return
if (inkey_active == TRUE)
{
return;
}
set(txtChatEntry,VISIBLE);
inkey(strChatEntry); // get chat entry
// if entry was empty don't process
if(str_cmp(strChatEntry,""))
{
return;
}
reset(txtChatEntry,VISIBLE);
str_cpy(strSendChat,player_name); // put players name before entry
str_cat(strSendChat,": ");
str_cat(strSendChat,strChatEntry);
// if Host go ahead and do chat manipulation
if (connection == 3)
{
send_string(strSendChat);
str_cpy(strChat0, strChat1);
str_cpy(strChat1, strChat2);
str_cpy(strChat2, strChat3);
str_cpy(strChat3, strChat4);
str_cpy(strChat4, strChat5);
str_cpy(strChat5, strChat6);
str_cpy(strChat6, strChat7);
str_cpy(strChat7, strChat8);
str_cpy(strChat8, strSendChat);
str_cpy(strSendChat,"");
}
else // if client send entry to server for processing
{
send_string(strSendChat);
}
str_cpy(strSendChat,""); // clear the strings for client and
str_cpy(strChatEntry,""); // server called functions
}
}
function save_screen()
{
file_for_screen("Multiplayer",1);
}
Meine/My acklog_cl Log of A7 Engine 7.07.6 run at Mon Jun 09 16:57:02 2008
Marc on Windows NT/2000/XP version 5.1 Build 2600
Options -cl -wnd -diag
App C:\Dokumente und Einstellungen\Marc\Desktop\MultiplayerSourceLite_C\MultiplayerSourceLite_C\multiplayer.cd\multiplayer.exe in C:\Dokumente und Einstellungen\Marc\Desktop\MultiplayerSourceLite_C\MultiplayerSourceLite_C\multiplayer.cd\
MM mixer opened
DSOUND device opened
DI interface opened
Start Window opened
(c)Conitec . Dieburg . San Diego . www.3dgamestudio.com
A7 Engine - Commercial Edition V7.07.6 - Jan 7 2008
DI Microsoft-PC-Joysticktreiber 3 axes 4 buttons initialized
Mouse found
Joystick found
Realtek HD Audio output opened
NVIDIA GeForce 8800 GTS pure T&L device 1ff9 detected
D3D device NVIDIA GeForce 8800 GTS 1ff9 selected
Loading MULTIPLAYER.EXE....
Compiling MULTIPLAYER.EXE - [Esc] to abort.... ....... .
Running MULTIPLAYER.EXE.
Searching for servers... session MULTIPLAYER found
Session MULTIPLAYER joined as Client13464631
9 objects
Main started
D3D_Init Window: 800x600 -> Window: 1x800x600x32
Video memory found: 548 MB...cmap,16 ents,1714 verts,6 lmaps,24 texs,2007 faces,pvs,hull
Physics restarted...ok
def_startup started
Main loop..........ok
1st frame - 561152K... ok Meine/My acklog_sv Log of A7 Engine 7.07.6 run at Mon Jun 09 16:56:51 2008
Marc on Windows NT/2000/XP version 5.1 Build 2600
Options -sv -diag
App C:\Dokumente und Einstellungen\Marc\Desktop\MultiplayerSourceLite_C\MultiplayerSourceLite_C\multiplayer.cd\multiplayer.exe in C:\Dokumente und Einstellungen\Marc\Desktop\MultiplayerSourceLite_C\MultiplayerSourceLite_C\multiplayer.cd\
Start Window opened
(c)Conitec . Dieburg . San Diego . www.3dgamestudio.com
A7 Engine - Commercial Edition V7.07.6 - Jan 7 2008
DI Microsoft-PC-Joysticktreiber 3 axes 4 buttons initialized
Loading MULTIPLAYER.EXE....
Compiling MULTIPLAYER.EXE - [Esc] to abort.... ....... .
Running MULTIPLAYER.EXE.
Starting server... marcs-core2duo 192.168.5.87 initialized
9 objects
Main started...cmap,16 ents,1714 verts,6 lmaps,24 texs,2007 faces,pvs,hull
Physics restarted...ok
def_startup started
Main loop........
Client13464631 joined
Normal exit
Close level,DLL,objects
Free input,funcs,panels,defs,syns,views,strings,vars..ok
Free sounds,bmaps,fonts,hash,defs1,script..ok
Close dx,multimedia,D3D,connection,engine,physics,nexus..ok
A7 Engine - Commercial Edition V7.07.6 - Jan 7 2008
(c)Conitec . Dieburg . San Diego . www.3dgamestudio.com
Close window
Last edited by virtualmarctek; 06/09/08 14:59.
mfg, Marc V.
|
|
|
Re: Multiplayer Source von Locoweed in Lite-C Problem
[Re: virtualmarctek]
#213911
07/01/08 13:34
07/01/08 13:34
|
Joined: Mar 2008
Posts: 68 Germany, Essen
virtualmarctek
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2008
Posts: 68
Germany, Essen
|
[DE]Weiß keiner eine Antwort[/DE] [EN]Has nobody an answer?[/EN]
Last edited by virtualmarctek; 07/01/08 13:35.
mfg, Marc V.
|
|
|
Re: Multiplayer Source von Locoweed in Lite-C Problem
[Re: virtualmarctek]
#213934
07/01/08 14:33
07/01/08 14:33
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
have you tried updating to the newest version
"empty"
|
|
|
|