Script Factory

Posted By: Slin

Script Factory - 05/02/07 13:35

I´m a bit bored and I´d like to script something. Following aztec, DwX and all the others before, I offer you, to post what kind of Script you´d like to have and I will try to realize it and post the working script here.

What I won´t do is pathfinding and menues.

Thanks
Slin
Posted By: Loopix

Re: Script Factory - 05/02/07 13:56

How about a simple script for handling a custom player name? Should be possible to:
-input the name string somewehre in the startmenu of the game
-calling the string (player name) whenever I want to

I know, this is not really challenging for you...but it would save me at least an hour
Posted By: aztec

Re: Script Factory - 05/02/07 13:59

Quote:

I´m a bit bored and I´d like to script something. Following aztec, DwX and all the others before, I offer you, to post what kind of Script you´d like to have and I will try to realize it and post the working script here.

What I won´t do is pathfinding and menues.

Thanks
Slin




First time ever that I´m an activator of something
hey but what I allways wanted to have is something like if you click on an object a text field opens where you can write something in.
now if thats right a new event happens
Regards
Aztec
Posted By: Slin

Re: Script Factory - 05/02/07 14:48

Loopix:
Code:

font font_Player = "arial",1,20;
string str_PlayerName = "Player";

text txt_PlayerNameIn
{
pos_x = 0;
pos_y = 0;
layer = 15;
font = font_Player;
strings = 2;
string = "Player Name: ",str_PlayerName;
}

function func_PlayerNameIn(PosX,PosY,SizeX,SizeY)
{
txt_PlayerNameIn.Pos_x = PosX;
txt_PlayerNameIn.Pos_y = PosY;

SizeX += PosX;
SizeY += PosY;

txt_PlayerNameIn.visible = on;

while(txt_PlayerNameIn.visible)
{
if( mouse_left
&& mouse_pos.x > PosX && mouse_pos.x < SizeX
&& mouse_pos.y > PosY && mouse_pos.y < SizeY)
{
inkey(str_PlayerName);
}

wait(1);
}
}



Just call the function "func_PlayerNameIn(PosX,PosY,SizeX,SizeY)" if you want to change the playername. PosX and PosY is the Position where the name gets displayed. You´ll have to click on the displayed text to change it so you have to say how big the text is with SizeX and SizeY.
If you want to make it invisible, just call txt_PlayerNameIn.visible = off; out of a function. The player name is stored in the string "str_PlayerName".

@aztec: I will try it when I´m done with my homework. It shouldn´t be very hard either
Posted By: Loopix

Re: Script Factory - 05/02/07 14:54

Wow...that was fast! Thanks a lot for this...you 're the champ
Posted By: Realspawn

Re: Script Factory - 05/02/07 18:42

i added this fun code to my wdl library online

thx

http://www.realspawn-productions.com/wdl/wdlindex
Posted By: Slin

Re: Script Factory - 05/02/07 18:42

This should be, what you are looking for aztec:

Code:

define EventString_count, 3; //Number of instructions

font font_EventInput = "arial",1,20;
string str_EventInput;

text txt_EventInput
{
pos_x = 0;
pos_y = 0;
layer = 15;
font = font_EventInput;
strings = 2;
string = "Instruction: ",str_EventInput;
}

text txt_EventInput_strings
{
strings = EventString_count;
string = "help","talk","trade"; //these are the posible instructions
}

function func_CompareStrings(StringIn) //Compare the strings
{
var counter;
while(counter < EventString_count)
{
if(str_cmpi(StringIn,txt_EventInput_strings.string[counter])){return(counter);}
counter += 1;
}
}

function func_EventInput(PosX,PosY)
{
var InkeyReturn;
var InstructionID;

txt_EventInput.Pos_x = PosX;
txt_EventInput.Pos_y = PosY;

txt_EventInput.visible = on;

InkeyReturn = inkey(str_EventInput);
if(1 < InkeyReturn < 27)
{
InstructionID = func_CompareStrings(str_EventInput);
}

txt_EventInput.visible = off;

if(InstructionID == 0) //if the input was help,
{
wait(1); //do something
}
if(InstructionID == 1) //if the input was talk,
{
wait(1); //do something
}
if(InstructionID == 2) //if the input was trade,
{
wait(1); //do something
}
}

function func_MdlEventInput_event()
{
if(event_type == event_click)
{
func_EventInput(mouse_pos.x,mouse_pos.y); //Place the text at the mouse position
}
}

action func_MdlEventInput() //Example Action
{
my.enable_click = on;
my.event = func_MdlEventInput_event;
}


Posted By: Inari

Re: Script Factory - 05/02/07 19:04

cool idea
Posted By: Realspawn

Re: Script Factory - 05/02/07 19:17

keep this work up
grinnn 2 codes more in the library
Posted By: Slin

Re: Script Factory - 05/02/07 19:29

Nice library, Realspawn

@all: I´ve got some time so please post what you´d like to get scriptet...


Slin
Posted By: Loopix

Re: Script Factory - 05/02/07 21:23

Well...if nobody else wants to get presents from such a skilled coder...here's my next wish

I have a day-night cycle depending on the sun_angle.pan (%360). Now I'd like to have an hour-day-month-year counter that depends on the sun_angle.pan (360' = one day...90'=noon, 270'=midnight)...Do you want to give it a go?
Posted By: JazzDude

Re: Script Factory - 05/02/07 22:32

Jeez...on any othe day I could have thot of a dozen requests.

What a time to go brain-dead!!
Posted By: MadMark

Re: Script Factory - 05/03/07 00:23

Okay, here comes one that I haven't been able to figure out for the life of me.

I have a spaceship model, and I move it through my level. When it gets to within 100 quants of the outside of a planet model, I would like it to orbit the planet, left to right, facing slightly towards the planet. I would like it to continue orbitting the sphere and present a menu to the player, allowing key input or mouse clicks on the menu, until the "X" key is pressed. Once pressed, the menu should disappear, the ship should smoothly turn away from the planet, escape orbit by 50 quants, and return steering to the player.

Problems that I have had are that the spheres are different sizes, and everything that I do seems to focus on the origin of the sphere and not its perimeter. I either end up inside the planet model, or way too far away.

Might be too much, but hey, you asked!

Cheers
Mark
Posted By: xXxGuitar511

Re: Script Factory - 05/03/07 01:06

lol, try using the min_x/max_x for finding the size, and then add an offset to it.

offset = 100;
distance = (my.max_x - my.min_x)/2 + offset;

This will return the distance [radius] from the origin of the model to use...
Posted By: Blink

Re: Script Factory - 05/03/07 01:17

i have a request... can you make a forcefield bubble code that only appears around the body of your player when hit? i want to use as a primary health and keep the actual health as secondary in a 3rd person shooter. so the code has to decrease after every hit, i guess it should have a max of 100 hp. can you do this? by the way, how can i use this code with a plbiped01 code in the templates?
Posted By: mpdeveloper_B

Re: Script Factory - 05/03/07 05:18

i also have a request, do you know how to do a quake3 style cheat code input system?
Posted By: Realspawn

Re: Script Factory - 05/03/07 06:18

at my library wdl online is a cheat input code dunno what quake style means
Posted By: Slin

Re: Script Factory - 05/03/07 11:51

@Loopix: Something like this should do it
Code:

define hours_a_day, 24;
define days_a_month, 30;
define months_a_year, 12;

define time_offset, 6;

var time_hour;
var time_day;
var time_month;
var time_year;

function TimeCounter()
{
var check;

while(1)
{
while(1)
{
time_hour = sun_angle.pan/(360/hours_a_day);
time_hour += time_offset;
time_hour %= hours_a_day;

if(time_hour > 0.9){check = 1;}
if(time_hour < 0.5 && check){check = 0; break;}

wait(1);
}

time_day += 1;

if(time_day == days_a_month)
{
time_day = 0;
time_month += 1;

if(time_month == months_a_year)
{
time_year += 1;
time_month = 0;
}
}

wait(1);
}
}



@Manslayer101: I don´t know either what you mean with quake3 style...
Posted By: Slin

Re: Script Factory - 05/03/07 12:45

@Blink: Try this
Code:

function Shield()
{
my.passable = on;
my.transparent = on;
my.red = 0;
my.green = 0;
my.blue = 255;
my.light = on;

you = my.parent;
vec_set(my.scale_x,you.scale_x);
vec_scale(my.scale_x,my.skill3);

var MaxEnergy;
MaxEnergy = my.skill1;

var Temp1;

while(you)
{
vec_set(my.x,you.x);
vec_set(my.pan,you.pan);

if(you.skill2 > 0){my.skill1 += min(my.skill1+you.skill2,MaxEnergy); you.skill2 = 0;}
if(you.skill1 < 100 && my.skill1 > 0)
{
my.alpha = my.skill2;
Temp1 = min(my.skill1,100-you.skill1);
my.skill1 -= Temp1;
you.skill1 += Temp1;
}
if(my.alpha > 0){my.alpha -= time_step;}

wait(1);
you = my.parent;
}
}

string ModelFileName;
function Shield_Activate(Pointer,ShieldEnergy,ShieldAlpha,ShieldScale)
{
you = Pointer;
if(you)
{
str_for_entfile(ModelFileName,you);

you = ent_create(ModelFileName,nullvector,Shield);
you.parent = Pointer;
you.skill1 = ShieldEnergy;
you.skill2 = ShieldAlpha;
you.skill3 = ShieldScale;
}
}



Add this at the top of the plBiped01.wdl (make a backup of that file before...)
and write this at the end of the action PlBiped01:
Shield_Activate(my,100,40,1.13);
The players armor is the shield enegy to start with.

I wasn´t able to test this so if you get any errors, just post your error message here.
Posted By: robertbruce

Re: Script Factory - 05/03/07 14:29

hello,

I would like the following script if you wouldn't mind.

When an entity/bot with an id between 2 to 8 hits an invisible block in it's path then it will jump forward.

I posted this here:

http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/749362/an/0/page/0#Post749362

thanks,

Rob
Posted By: Loopix

Re: Script Factory - 05/03/07 15:33

THIS IS FANTASTIC!!! The script works perfect...I could never have done it in a reasonable time frame. Big thanks once again...and keep it up
Posted By: Slin

Re: Script Factory - 05/03/07 17:05

Quote:

Okay, here comes one that I haven't been able to figure out for the life of me.

I have a spaceship model, and I move it through my level. When it gets to within 100 quants of the outside of a planet model, I would like it to orbit the planet, left to right, facing slightly towards the planet. I would like it to continue orbitting the sphere and present a menu to the player, allowing key input or mouse clicks on the menu, until the "X" key is pressed. Once pressed, the menu should disappear, the ship should smoothly turn away from the planet, escape orbit by 50 quants, and return steering to the player.

Problems that I have had are that the spheres are different sizes, and everything that I do seems to focus on the origin of the sphere and not its perimeter. I either end up inside the planet model, or way too far away.

Might be too much, but hey, you asked!

Cheers
Mark





What are you exactly looking for?
Do you already have something working (like the shipcontrol), or shall I try to script everything from ground up? If so, It would be very nice if you could create a small level with at least the two models, because I don´t realy like creating levels and models... If you do so, I´ll give it a try.
Posted By: Slin

Re: Script Factory - 05/03/07 18:33

Try this one robertbruce:
Code:

//skill1: TurnSpeed 10
//skill2: MoveSpeed 10
//skill3: JumpHeight 10
//skill4: JumpNode1 1
//skill5: JumpNode2 2
//skill6: JumpNode3 3
//skill7: JumpNode4 4
//skill8: JumpNode5 5
//skill9: JumpNode6 6
//skill10: JumpNode7 7
//skill11: JumpNode8 8
//skill12: JumpNode9 9
//skill13: JumpNode10 10
//flag1: JumpEveryNode
action patrol_path()
{
// attach entity to nearest path
result = path_scan(me,my.x,my.pan,vector(360,180,1000);
if (result == 0) { return; } // no path found

var NodePos[3];

// find first waypoint
var node = 1; // start at first node
path_getnode(my,node,NodePos,NULL);

var angle[3];

var Gravity;

while (1)
{
// find direction
result = vec_to_angle(angle,vec_diff(temp,NodePos,my.x));

// near target? Find next waypoint of the path
if (result < 25)
{
if(my.JumpEveryNode == on || node == my.JumpNode1 || node == my.JumpNode2
|| node == my.JumpNode3 || node == my.JumpNode4 || node == my.JumpNode5
|| node == my.JumpNode6 || node == my.JumpNode7 || node == my.JumpNode8
|| node == my.JumpNode9 || node == my.JumpNode10)
{
Gravity = my.JumpHeight;
}

node = path_nextnode(my,node,1);
path_getnode(my,node,NodePos,NULL);
}

my.skill21 = c_trace(my.x,vector(0,0,-10000),use_box|ignore_me|ignore_passents|ignore_passable);
if(my.skill21 > 5)
{
Gravity -= time_step;
}else
{
if(my.skill21 < 0)
{
Gravity += time_step;
}else
{
Gravity = 0;
}
}

// turn and walk towards target
my.pan += ((angle.pan > my.pan)-(angle.pan < my.pan))*time_step*my.TurnSpeed;
c_move(me,vector(my.MoveSpeed*time_step,0,Gravity),nullvector,glide|ignore_passents|ignore_passable);

wait(1);
}
}



But this is more the answer to your thread...
Posted By: Sam_Be

Re: Script Factory - 05/03/07 20:22

could you make a script that makes some models follow the player?' for example in shooter games there are often many (two or 3) worriers fighting against the enamie, so they have to follow the player and help him fighting the bad guys.
could you make that??
thanks
sam
Posted By: Mondivirtuali

Re: Script Factory - 05/04/07 10:01

I have a request too: perhaps put together the player combat script from A5 templates with the sword combat from AUM 12, so a player can fight with a zombie\monster\ogres, shooting them while the monster try to kill him with swords, axes, bare hands..just like the first Quake.
Posted By: aztec

Re: Script Factory - 05/04/07 10:20

Oh and maybe I good save and load system if you know what I mean
Posted By: jigalypuff

Re: Script Factory - 05/04/07 12:48

i`d love a star trek style phaser with targeting code, pretty pretty please
Posted By: mpdeveloper_B

Re: Script Factory - 05/04/07 17:07

could you do quake3 style cheat console?
Posted By: Realspawn

Re: Script Factory - 05/04/07 18:00

perhaps you didn't see my answer about the cheat code thingie ?
Posted By: Blink

Re: Script Factory - 05/04/07 22:21

Slin, quick question, in the force bubble code you gave me, where it says modelnamefile, does it mean, model that will be using the code, or bubble model used for force shield? stupid question, i know.
Posted By: Slin

Re: Script Factory - 05/04/07 23:02

It´s both
The modelfilename is copied into that string and then used for forcefield.

@all the others, I will have a look at your requests in the evening (it´s 1 am now...).
Posted By: Blink

Re: Script Factory - 05/04/07 23:03

Slin, here is what i did, doesnt work. no errors though.

Code:
 ifndef plBiped_wdl;
define plBiped_wdl;

// ---------------------------------------------------------------------
// STARTHEADER
//
// ver: 5.0
// engineReq: 6.4
// date: 061011
//
// title: Biped Player (01)
// class: PLAYER
// type: USER
// image: plBiped01.pcx
// help: Action to attach to a "biped model" that you want the player to control.
//
// note: You can only have one PlBiped in your level.
//
// needs: gid01.wdl
// needs: plSelect.wdl, cameraTarget.wdl
// needs: miscInput01.wdl, plBipedInput01.wdl
// needs: bipedPhy01.wdl,
// needs: bipedAnim01.wdl, bipedSnd01.wdl
//
// external: plSelect::plSelect_curr_model, ++++++++
//
// prefix: plBiped01_
// idcode: 012
//
// ENDHEADER
// ---------------------------------------------------------------------


// entry: ID
// help: Identification number for this player model (used in plSelect)
// help: NOTE: Action not defined if two player models share a single value
// id: 1
define plBiped01_id = 1;


// entry: "Head" offset vector
// help: Distance between model center and the 'head' of the player
// help: Used for camera view.
// id: 2
var plBiped01_head_offset_vec[3] = 0,0,33;

// ---------------------------------------------------------------------
// section: Activation Scan Segment

// entry: Width
// help: Horizontal width of the activate segment
// id: 3
define plBiped01_activate_scan_horz_width = 60;
// entry: Height
// help: Vertical height of the activate segment
// id: 4
define plBiped01_activate_scan_vert_width = 60;
// entry: Range
// help: Range of activate scan
// id: 5
define plBiped01_activate_scan_range = 100;


// ---------------------------------------------------------------------
// section: Health and Armor Limits

// entry: Max Health
// help: Player can not have more health then this.
// id: 7
define plBiped01_max_health = 100;

// entry: Max Armor
// help: Player can not have more armor then this.
// id: 8
define plBiped01_max_armor = 100;


// ---------------------------------------------------------------------
// section: Damage

// enable: Display Damage panel?
// id: 10
define PLBIPED01_DAMAGEPAN;

ifdef PLBIPED01_DAMAGEPAN;
// entry: Damage Bitmap
// help: Displayed for a brief time when player takes damage
// id: 9
bmap plBiped01_danage_map = <bloodhit.tga>;
panel plBiped01_damage_pan { bmap = plBiped01_danage_map; layer = 98; flags = refresh, d3d, transparent; }

// Desc: Display damage panel for a brief time

function Shield()
{
my.passable = on;
my.transparent = on;
my.red = 0;
my.green = 0;
my.blue = 255;
my.light = on;

you = my.parent;
vec_set(my.scale_x,you.scale_x);
vec_scale(my.scale_x,my.skill3);

var MaxEnergy;
MaxEnergy = my.skill1;

var Temp1;

while(you)
{
vec_set(my.x,you.x);
vec_set(my.pan,you.pan);

if(you.skill2 > 0){my.skill1 += min(my.skill1+you.skill2,MaxEnergy); you.skill2 = 0;}
if(you.skill1 < 100 && my.skill1 > 0)
{
my.alpha = my.skill2;
Temp1 = min(my.skill1,100-you.skill1);
my.skill1 -= Temp1;
you.skill1 += Temp1;
}
if(my.alpha > 0){my.alpha -= time_step;}
wait(1);
you = my.parent;
}
}
string keisha1_mdl = <keisha1.mdl>;
function Shield_Activate(Pointer,ShieldEnergy,ShieldAlpha,ShieldScale)
{
you = Pointer;
if(you)
{
str_for_entfile(keisha1_mdl,you);

you = ent_create(keisha1_mdl,nullvector,Shield);
you.parent = Pointer;
you.skill1 = ShieldEnergy;
you.skill2 = ShieldAlpha;
you.skill3 = ShieldScale;
}
}
function PlBiped_Display_Damage()
{
if(plBiped01_damage_pan.visible == off)
{
plBiped01_damage_pan.visible = on;
plBiped01_damage_pan.scale_x = (screen_size.x/bmap_width(plBiped01_danage_map));
plBiped01_damage_pan.scale_y = (screen_size.y/bmap_height(plBiped01_danage_map));
plBiped01_damage_pan.pos_x = 0;
plBiped01_damage_pan.pos_y = 0;
plBiped01_damage_pan.alpha = 75;
while(plBiped01_damage_pan.alpha > 10)
{
plBiped01_damage_pan.alpha - = 10 * time_step;
wait(1);
}
plBiped01_damage_pan.visible = off;
}
}
endif; // PLBIPED01_DAMAGEPAN

// Desc: React to damage taken (sound, blood, etc.)
function PlBiped_Damage_Reaction()
{
ifdef PLBIPED01_DAMAGEPAN;
PlBiped_Display_Damage();
endif;

return;
}



// ---------------------------------------------------------------------
// section: Death

// entry: Death Bitmap
// help: This is the bmp the screen will fade to on death.
// id: 6
bmap plBiped01_death_bmp = <gigmov.tga>;
panel plBiped01_death_pan { bmap = plBiped01_death_bmp; layer = 99; flags = refresh,d3d; }



// head angle. used for when view angle changes independently of the player angle
var plBiped01_head_ang_vec[3];

// pointer to the biped entity
entity* plBiped01_entity;




/*
// forces taking from player input
var plBiped01_force_vec[3]; // x,y,z forces
var plBiped01_ang_force_vec[3]; // pan,tile,roll forces
var plBiped01_flag_array[3]; // 48 bit-encoded flags (used for various actions)
*/


// Local Function Prototypes
function PlBiped01_Activate(); // activate the biped model
function PlBiped01_Deactivate(); // deactivate the biped model
function PlBiped01_Update(); // update mode (call once per frame while active)
function PlBiped_Death(); // handle death

// ---------------------------------------------------------------------
// FUNCTIONS

// Desc: Check to make sure limits are not being exceeded.
function PlBiped01_CheckLimits()
{
if(plBiped01_entity._health__003 > plBiped01_max_health) { plBiped01_entity._health__003 = plBiped01_max_health; }
if(plBiped01_entity._armor__003 > plBiped01_max_armor) { plBiped01_entity._armor__003 = plBiped01_max_armor; }
}

// Desc: Initialize the starting values, add biped model to plSelect list,
// and execute the main update loop.
function PlBiped01_Init()
{
var updated_b; // has the model been update yet this frame?
var bit_check; // bit-field check value

// wait until we have a valid player biped...
while(plBiped01_entity == null)
{
wait(1);
}

diag("\nWDL-Loaded:plBiped01.wdl");


// init bit-field value used to check to see if this model is active
bit_check = 1<<plBiped01_id;

// increase the player select "max_model" value if this value fall outside the current range
if(bit_check > plSelect_max_model)
{ plSelect_max_model = bit_check; }

// add this model type to the collection of valid model types in player select
plSelect_valid_models |= bit_check;

while(1)
{
// only act if we have a valid entity...
if(plBiped01_entity != null)
{
updated_b = 0; // model hasn't been updated yet this frame

// if we are the active model
if(plBiped01_id == plSelect_curr_model)
{
// Activate the biped model
PlBiped01_Activate();

// while this model is active...
while(plBiped01_id == plSelect_curr_model)
{
if(gid01_level_state == gid01_level_loaded)
{
if(my._health__003 > 0)
{
// Update the biped model
PlBiped01_Update();
plSelect_state = plSelect_state_active; // player is active
}
else
{
// handle death
PlBiped_Death();
plSelect_state = plSelect_state_dead; // player is dead
}

// Update the camera target
cameraTarget_ent = plBiped01_entity;
vec_set(cameraTarget_pos_vec,plBiped01_entity.x);
vec_add(cameraTarget_pos_vec,plBiped01_head_offset_vec);
if(my._biped01_state == biped01_state_duck_const)
{
cameraTarget_pos_vec.z -= my._duck_height__003;
}
vec_set(cameraTarget_ang_vec,plBiped01_entity.pan);
vec_add(cameraTarget_ang_vec,plBiped01_head_ang_vec);
}
else
{
diag("\nPlayer Biped is waiting...");
}


wait(1);
}


// Deactivate the biped model
PlBiped01_Deactivate();

}
}
wait(1); // every frame
}

}

// Desc: update the head angle depending on vector
function PlBiped01_Head_Update(&ang_vec)
{
vec_add(plBiped01_head_ang_vec,ang_vec);
// Limits
if(plBiped01_head_ang_vec.tilt > 85) { plBiped01_head_ang_vec.tilt = 85; }
if(plBiped01_head_ang_vec.tilt < -85) { plBiped01_head_ang_vec.tilt = -85; }
}


// ---------------------------------------------------------------------

// Desc: activate the biped model
function PlBiped01_Activate()
{
// set the player select current entity to this biped entity
plSelect_curr_ent = plBiped01_entity;

// make sure they are visible
plBiped01_entity.invisible = off;
plBiped01_entity.passable = off;

}

// Desc: deactivate the biped model
function PlBiped01_Deactivate()
{
// hide the player biped
plBiped01_entity.invisible = on;
plBiped01_entity.passable = on;

//++ToDo: make this optional
}




// Desc: fade the camera to black (Simulating death)
function PlBiped_Death()
{
// only enter once
// note: this works because the state is set after this call!
if(plSelect_state == plSelect_state_dead) { return; }


plBiped01_death_pan.scale_x = (screen_size.x/bmap_width(plBiped01_death_bmp));
plBiped01_death_pan.scale_y = (screen_size.y/bmap_height(plBiped01_death_bmp));
plBiped01_death_pan.pos_x = 0;
plBiped01_death_pan.pos_y = 0;
plBiped01_death_pan.visible = on;
Clib_Panel_Fade(plBiped01_death_pan,5,100,3);
wait(1); // NOTE: We need this wait because plSelect_state_dead is not set until after this function is called
while(plSelect_state == plSelect_state_dead)
{
wait(1);
}

// we should reach here only if the player heath is > 0
plBiped01_death_pan.visible = off;
}

// Desc: update mode (call once per frame while active)
function PlBiped01_Update()
{
// this function modifies/reads the current player biped entity
my = plBiped01_entity;

// Get player input
PlBipedInput01_Update();


// handle headmovement (use 'tilt' from player input
PlBiped01_Head_Update(vector(0,plBiped01_ang_force_vec.tilt,0));

// scale rotation and linear input by the force modifiers
if(0 == plBipedInput01_mouse_look_q) // not using mouse look...
{
if(0 == mouse_moving) // ..and mouse not moving
{
plBiped01_ang_force_vec.pan *= my._max_ang_force_pan__003 * time_step;
}
}
plBiped01_ang_force_vec.tilt = 0; // do not use tilt from player input to handle biped movement
plBiped01_ang_force_vec.roll = 0; // do not use roll from player input to handle biped movement
plBiped01_force_vec.x *= my._max_force_x__003;
plBiped01_force_vec.y *= my._max_force_y__003;
plBiped01_force_vec.z *= my._max_force_y__003;


// Send forces/flags to biped01 update (which will handle physics, animation, and sound)
BipedPhy01_Update(plBiped01_force_vec, plBiped01_ang_force_vec.pan);

// Handle player specific results from biped update
if(my._biped01_state2_mod == biped01_state_mod_damage_const)
{
// handle any damage from biped update (falling, crushing, etc)
my._health__003 -= my._biped01_state2_mod_value; // take damage (bipass armor)
my._biped01_state2_mod = biped01_state2_mod_none_const; // reset flag
}

// Handle drowning damage
if(my._biped01_state_mod == biped01_state_mod_drown_const)
{
// handle any damage from drowning (time based)
my._health__003 -= bipedPhy01_drowning_damage_const*time_step;
}


// Check flags

// Activation scan?
if(plBiped01_flag_array[0] & plBipedInput01_flag0_activate)
{
gid01_event_type = gid01_event_scan_activate;
}
else // or passive scan?
{
gid01_event_type = gid01_event_scan_passive;
}
temp[0] = plBiped01_activate_scan_horz_width;
temp[1] = plBiped01_activate_scan_vert_width;
temp[2] = plBiped01_activate_scan_range;
//scan_entity(my.x,temp);
if(1 == cameraTarget_avatar_view_q )
{
// use camera center/facing
c_scan(cameraTarget_pos_vec.x,cameraTarget_ang_vec.pan,temp,IGNORE_ME | IGNORE_YOU | SCAN_ENTS | SCAN_LIMIT );
}
else
{
// use model center/facing
c_scan(my.x,my.pan,temp,IGNORE_ME | IGNORE_YOU | SCAN_ENTS | SCAN_LIMIT );
}

}


// Desc: handle player biped events
function PlBiped01_Event()
{

if((EVENT_TYPE == event_shoot) && (gid01_event_type == gid01_event_projectile_damage))
{
if(my._armor__003 > 0)
{
my._armor__003 -= gid01_event_value;

if(my._armor__003 < 0)
{
// flesh damage after armor damage
my._health__003 += my._armor__003;
my._armor__003 = 0;
PlBiped_Damage_Reaction(); // display damage panel
}
}
else
{ // take flesh damage
my._health__003 -= gid01_event_value;
PlBiped_Damage_Reaction(); // display damage panel
}
}

// handle scan events
if(EVENT_SCAN == EVENT_TYPE)
{
if(gid01_event_blast_damage == gid01_event_type)
{

// trace back to the blast source
if(1) // ++ fix c_trace(your.x,my.x,(ignore_me+ignore_you+ignore_passable+ignore_passents)) == 0)
{
if(my._armor__003 > 0)
{
my._armor__003 -= gid01_event_value;

if(my._armor__003 < 0)
{
// flesh damage after armor damage
my._health__003 += my._armor__003;
my._armor__003 = 0;
PlBiped_Damage_Reaction(); // display damage panel
}

}
else
{ // take flesh damage
my._health__003 -= gid01_event_value;
PlBiped_Damage_Reaction(); // display damage panel
}
}
}
}



// door/lift hit player
if((EVENT_TYPE == event_push))
{
if((gid01_event_type == gid01_event_push))
{
// alert "pusher" we got the event
you._gid01_message = 1; // send message back to door/lift


// take damage
my._health__003 -= gid01_event_value;
}
}


}



// ---------------------------------------------------------------------
// ACTIONS

///////////////////////////////////////////////////////////////////////
// Entity skill & flag definitions




// action: PlBiped01
// title: Biped (i.e. Human) Player Entity
// Desc: Action attached to the player entity
// Desc: Note: only valid if used once per level!
//
// uses _max_force_x__003, _max_force_y__003
// uses _max_ang_force_pan__003, _force_mult_003, _trigger_range__003
// uses _move_min_z__003, _jump_height__003, _duck_height__003
// uses _walkswim_dist__002, _runcrawl_dist__002, _standjump_time__002
// uses _attackduck_time__002, _deathdamage_time__002, _runthreshold__002
// uses _health__003, _armor__003, _no_fall_dam__003
//
//------------------
// section: Heath & Armor
// skill1: Health 100
// cntl: spin 1 x 5
// help: Reduced by damage. When <=0, player dies.
//
// skill2: Armor 0
// cntl: spin 0 x 5
// help: Reduces the damage that would otherwise be taken from health.
//
//------------------
// section: Movement
// skill3: ForceX 7.5
// help: Forward force used to calculate player speed.
// cntl: spin 0 x 0.25
//
// skill4: ForceY 3.75
// help: Force used to calculate player "side-step" speed.
// help: Also used for climbing and swimming up/down.
// cntl: spin 0 x 0.25
//
// skill6: Pan 10
// help: Force used to calculate the player's rotation speed.
// cntl: spin 0 x 0.25
//
// skill8: ForceMult 0.5
// help: Force multiplier when run/walk key is pressed:
/// > 1, player goes faster
/// < 1, player goes slower
// cntl: spin 0 x 0.25
//
//------------------
// section: Limits
//
// skill9: MinMoveZ 0.25
// help: Used to adjust the amount of upward sliding the player can do.
// help: 0-can slide up onto anything under half its height, 0.99 no upward sliding.
// cntl: spin 0 0.99 0.05
//
// skill10: Jump 75
// help: Height that the player tries to jump to.
// cntl: spin 0 x 1
//
// skill11: Duck 20
// help: How far the player can duck down.
// cntl: spin 0 x 1
//
// flag1: NoFallDamage 0
// help: If set, player takes no falling damage.
//
//------------------
// section: Animation
// skill12: WalkSwimDist 4.04
// help: Walk.Swim animation cycle distance.
// help: The value before the '.' calculates distance traveled to complete a walking cycle.
// help: The value after the '.' calculates distance traveled to complete a swimming cycle.
// cntl: spin 0 x 1
//
// skill13: RunCrawlDist 6.03
// help: Run.Crawl animation cycle distance.
// help: The value before the '.' calculates distance traveled to complete a run cycle.
// help: The value after the '.' calculates distance traveled to complete a crawling cycle.
// cntl: spin 0 x 1
//
// skill14: StandJumpTime 4.02
// help: Time in Stand.Jump animation cycle.
// cntl: spin 0 x 1
//
// skill15: AttackDuckTime 4.02
// help: Time in Attack.Duck animation cycle.
// cntl: spin 0 x 1
//
// skill16: DeathDamageTime 12.02
// help: Time in Death.Damage animation cycle.
// cntl: spin 0 x 1
//
// skill17: RunThreshold 12
// help: If player is moving faster then this many quants,
/// use running animation, otherwise use walking.
// cntl: spin 1 x 1
//
//------------------
// section: Misc.
// skill7: TriggerRange 25
// help: Used when the player tries to "trigger" something (i.e. pick up)
// cntl: spin 0 x 1
//
action PlBiped01
{
//watched = my; // uncomment to 'watch' the player
if(plBiped01_entity != 0)
{
diag("\nWARNING! PlBiped01::PlBiped01- Two or more PlBiped01 entities in level.");
wait(1); ent_remove(me);
return;
}

// setup for collision
wait(1);
BipedPhy01_Setup_Ent();

// upward glide
if(my._move_min_z__003 > 0.99)
{
my._move_min_z__003 = 0.99;
}
if(my._move_min_z__003 < 0)
{
my._move_min_z__003 = 0;
}

Shield_Activate(my,100,40,1.13);

// set global player biped entity pointer to this object
plBiped01_entity = me;

// set id to player
my._gid01_id = gid01_player_const;

/////////////////////////////////////////////////////////////
// set up player specific variables (use defaults as needed)

// default health
if(my._health__003 == 0) { my._health__003 = 100; }
// default forces
if(my._max_force_x__003 == 0) { my._max_force_x__003 = 7.5; }
if(my._max_force_y__003 == 0) { my._max_force_y__003 = 3.75; }
if(my._max_ang_force_pan__003 == 0) { my._max_ang_force_pan__003 = 10.0; }
// default jump height
if(my._jump_height__003 == 0) { my._jump_height__003 = 75.0; }

// default animation values
if(my._walkswim_dist__002 == 0) // walk distance . swim distance
{
my._walkswim_dist__002 = 4.04;
}
if(my._runcrawl_dist__002 == 0) // run distance . crawl distance
{
my._runcrawl_dist__002 = 6.03;
}
if(my._standjump_time__002 == 0) // stand time . jump time
{
my._standjump_time__002 = 4.02;
}
if(my._attackduck_time__002 == 0) // attack time . duck time
{
my._attackduck_time__002 = 4.02;
}
if(my._deathdamage_time__002 == 0) // death time . damage time
{
my._deathdamage_time__002 = 12.02;
}
if(my._runthreshold__002 == 0) // run threshold
{
my._runthreshold__002 = 12;
}

if(my._trigger_range__003 == 0)
{
my.trigger_range = 5;
}
else
{
if(my._trigger_range__003 < 0) { my.trigger_range = 0; }
else { my.trigger_range = my._trigger_range__003; }
}


// set up event handler
my.event = PlBiped01_Event;
my.enable_shoot = on; // gun shoot
my.enable_scan = on; // explosions
my.enable_push = on; // stop/take damage from certain doors and platforms

// Call the biped setup function
PlBiped01_Init();


// Start the animation update loop (runs until biped is removed)
BipedAnim01_Update_Loop();
// Start the sound loop (runs until biped is removed)
BipedSnd01_Update_Loop();
}


endif;


Posted By: Slin

Re: Script Factory - 05/04/07 23:31

Uncomment these two lines:
str_for_entfile(keisha1_mdl,you);
vec_set(my.scale_x,you.scale_x);

But this shouldn´t really change much, I will have a look at it later.
Posted By: Blink

Re: Script Factory - 05/05/07 07:32

it didnt change at all, still no force field.
Posted By: Slin

Re: Script Factory - 05/05/07 22:58

@Blink:
At least I learned how to use the A6 Templates, today and that my computer don´t like them (reboot after some time if I use them).

At least this worked for me:
Code:

ifndef plBiped_wdl;
define plBiped_wdl;

// ---------------------------------------------------------------------
// STARTHEADER
//
// ver: 5.0
// engineReq: 6.4
// date: 061011
//
// title: Biped Player (01)
// class: PLAYER
// type: USER
// image: plBiped01.pcx
// help: Action to attach to a "biped model" that you want the player to control.
//
// note: You can only have one PlBiped in your level.
//
// needs: gid01.wdl
// needs: plSelect.wdl, cameraTarget.wdl
// needs: miscInput01.wdl, plBipedInput01.wdl
// needs: bipedPhy01.wdl,
// needs: bipedAnim01.wdl, bipedSnd01.wdl
//
// external: plSelect::plSelect_curr_model, ++++++++
//
// prefix: plBiped01_
// idcode: 012
//
// ENDHEADER
// ---------------------------------------------------------------------


// entry: ID
// help: Identification number for this player model (used in plSelect)
// help: NOTE: Action not defined if two player models share a single value
// id: 1
define plBiped01_id = 1;


// entry: "Head" offset vector
// help: Distance between model center and the 'head' of the player
// help: Used for camera view.
// id: 2
var plBiped01_head_offset_vec[3] = 0,0,33;

// ---------------------------------------------------------------------
// section: Activation Scan Segment

// entry: Width
// help: Horizontal width of the activate segment
// id: 3
define plBiped01_activate_scan_horz_width = 60;
// entry: Height
// help: Vertical height of the activate segment
// id: 4
define plBiped01_activate_scan_vert_width = 60;
// entry: Range
// help: Range of activate scan
// id: 5
define plBiped01_activate_scan_range = 100;


// ---------------------------------------------------------------------
// section: Health and Armor Limits

// entry: Max Health
// help: Player can not have more health then this.
// id: 7
define plBiped01_max_health = 100;

// entry: Max Armor
// help: Player can not have more armor then this.
// id: 8
define plBiped01_max_armor = 100;


// ---------------------------------------------------------------------
// section: Damage

// enable: Display Damage panel?
// id: 10
define PLBIPED01_DAMAGEPAN;

ifdef PLBIPED01_DAMAGEPAN;
// entry: Damage Bitmap
// help: Displayed for a brief time when player takes damage
// id: 9
bmap plBiped01_danage_map = <bloodhit.tga>;
panel plBiped01_damage_pan { bmap = plBiped01_danage_map; layer = 98; flags = refresh, d3d, transparent; }

// Desc: Display damage panel for a brief time
function PlBiped_Display_Damage()
{
if(plBiped01_damage_pan.visible == off)
{
plBiped01_damage_pan.visible = on;
plBiped01_damage_pan.scale_x = (screen_size.x/bmap_width(plBiped01_danage_map));
plBiped01_damage_pan.scale_y = (screen_size.y/bmap_height(plBiped01_danage_map));
plBiped01_damage_pan.pos_x = 0;
plBiped01_damage_pan.pos_y = 0;
plBiped01_damage_pan.alpha = 75;
while(plBiped01_damage_pan.alpha > 10)
{
plBiped01_damage_pan.alpha - = 10 * time_step;
wait(1);
}
plBiped01_damage_pan.visible = off;
}
}
endif; // PLBIPED01_DAMAGEPAN

// Desc: React to damage taken (sound, blood, etc.)
function PlBiped_Damage_Reaction()
{
ifdef PLBIPED01_DAMAGEPAN;
PlBiped_Display_Damage();
endif;

return;
}



// ---------------------------------------------------------------------
// section: Death

// entry: Death Bitmap
// help: This is the bmp the screen will fade to on death.
// id: 6
bmap plBiped01_death_bmp = <black.pcx>;
panel plBiped01_death_pan { bmap = plBiped01_death_bmp; layer = 99; flags = refresh,d3d; }



// head angle. used for when view angle changes independently of the player angle
var plBiped01_head_ang_vec[3];

// pointer to the biped entity
entity* plBiped01_entity;




/*
// forces taking from player input
var plBiped01_force_vec[3]; // x,y,z forces
var plBiped01_ang_force_vec[3]; // pan,tile,roll forces
var plBiped01_flag_array[3]; // 48 bit-encoded flags (used for various actions)
*/


// Local Function Prototypes
function PlBiped01_Activate(); // activate the biped model
function PlBiped01_Deactivate(); // deactivate the biped model
function PlBiped01_Update(); // update mode (call once per frame while active)
function PlBiped_Death(); // handle death

// ---------------------------------------------------------------------
// FUNCTIONS

// Desc: Check to make sure limits are not being exceeded.
function PlBiped01_CheckLimits()
{
if(plBiped01_entity._health__003 > plBiped01_max_health) { plBiped01_entity._health__003 = plBiped01_max_health; }
if(plBiped01_entity._armor__003 > plBiped01_max_armor) { plBiped01_entity._armor__003 = plBiped01_max_armor; }
}

// Desc: Initialize the starting values, add biped model to plSelect list,
// and execute the main update loop.
function PlBiped01_Init()
{
var updated_b; // has the model been update yet this frame?
var bit_check; // bit-field check value

// wait until we have a valid player biped...
while(plBiped01_entity == null)
{
wait(1);
}

diag("\nWDL-Loaded:plBiped01.wdl");


// init bit-field value used to check to see if this model is active
bit_check = 1<<plBiped01_id;

// increase the player select "max_model" value if this value fall outside the current range
if(bit_check > plSelect_max_model)
{ plSelect_max_model = bit_check; }

// add this model type to the collection of valid model types in player select
plSelect_valid_models |= bit_check;

while(1)
{
// only act if we have a valid entity...
if(plBiped01_entity != null)
{
updated_b = 0; // model hasn't been updated yet this frame

// if we are the active model
if(plBiped01_id == plSelect_curr_model)
{
// Activate the biped model
PlBiped01_Activate();

// while this model is active...
while(plBiped01_id == plSelect_curr_model)
{
if(gid01_level_state == gid01_level_loaded)
{
if(my._health__003 > 0)
{
// Update the biped model
PlBiped01_Update();
plSelect_state = plSelect_state_active; // player is active
}
else
{
// handle death
PlBiped_Death();
plSelect_state = plSelect_state_dead; // player is dead
}

// Update the camera target
cameraTarget_ent = plBiped01_entity;
vec_set(cameraTarget_pos_vec,plBiped01_entity.x);
vec_add(cameraTarget_pos_vec,plBiped01_head_offset_vec);
if(my._biped01_state == biped01_state_duck_const)
{
cameraTarget_pos_vec.z -= my._duck_height__003;
}
vec_set(cameraTarget_ang_vec,plBiped01_entity.pan);
vec_add(cameraTarget_ang_vec,plBiped01_head_ang_vec);
}
else
{
diag("\nPlayer Biped is waiting...");
}


wait(1);
}


// Deactivate the biped model
PlBiped01_Deactivate();

}
}
wait(1); // every frame
}

}

// Desc: update the head angle depending on vector
function PlBiped01_Head_Update(&ang_vec)
{
vec_add(plBiped01_head_ang_vec,ang_vec);
// Limits
if(plBiped01_head_ang_vec.tilt > 85) { plBiped01_head_ang_vec.tilt = 85; }
if(plBiped01_head_ang_vec.tilt < -85) { plBiped01_head_ang_vec.tilt = -85; }
}


// ---------------------------------------------------------------------

// Desc: activate the biped model
function PlBiped01_Activate()
{
// set the player select current entity to this biped entity
plSelect_curr_ent = plBiped01_entity;

// make sure they are visible
plBiped01_entity.invisible = off;
plBiped01_entity.passable = off;

}

// Desc: deactivate the biped model
function PlBiped01_Deactivate()
{
// hide the player biped
plBiped01_entity.invisible = on;
plBiped01_entity.passable = on;

//++ToDo: make this optional
}




// Desc: fade the camera to black (Simulating death)
function PlBiped_Death()
{
// only enter once
// note: this works because the state is set after this call!
if(plSelect_state == plSelect_state_dead) { return; }


plBiped01_death_pan.scale_x = (screen_size.x/bmap_width(plBiped01_death_bmp));
plBiped01_death_pan.scale_y = (screen_size.y/bmap_height(plBiped01_death_bmp));
plBiped01_death_pan.pos_x = 0;
plBiped01_death_pan.pos_y = 0;
plBiped01_death_pan.visible = on;
Clib_Panel_Fade(plBiped01_death_pan,5,100,3);
wait(1); // NOTE: We need this wait because plSelect_state_dead is not set until after this function is called
while(plSelect_state == plSelect_state_dead)
{
wait(1);
}

// we should reach here only if the player heath is > 0
plBiped01_death_pan.visible = off;
}

// Desc: update mode (call once per frame while active)
function PlBiped01_Update()
{
// this function modifies/reads the current player biped entity
my = plBiped01_entity;

// Get player input
PlBipedInput01_Update();


// handle headmovement (use 'tilt' from player input
PlBiped01_Head_Update(vector(0,plBiped01_ang_force_vec.tilt,0));

// scale rotation and linear input by the force modifiers
if(0 == plBipedInput01_mouse_look_q) // not using mouse look...
{
if(0 == mouse_moving) // ..and mouse not moving
{
plBiped01_ang_force_vec.pan *= my._max_ang_force_pan__003 * time_step;
}
}
plBiped01_ang_force_vec.tilt = 0; // do not use tilt from player input to handle biped movement
plBiped01_ang_force_vec.roll = 0; // do not use roll from player input to handle biped movement
plBiped01_force_vec.x *= my._max_force_x__003;
plBiped01_force_vec.y *= my._max_force_y__003;
plBiped01_force_vec.z *= my._max_force_y__003;


// Send forces/flags to biped01 update (which will handle physics, animation, and sound)
BipedPhy01_Update(plBiped01_force_vec, plBiped01_ang_force_vec.pan);

// Handle player specific results from biped update
if(my._biped01_state2_mod == biped01_state_mod_damage_const)
{
// handle any damage from biped update (falling, crushing, etc)
my._health__003 -= my._biped01_state2_mod_value; // take damage (bipass armor)
my._biped01_state2_mod = biped01_state2_mod_none_const; // reset flag
}

// Handle drowning damage
if(my._biped01_state_mod == biped01_state_mod_drown_const)
{
// handle any damage from drowning (time based)
my._health__003 -= bipedPhy01_drowning_damage_const*time_step;
}


// Check flags

// Activation scan?
if(plBiped01_flag_array[0] & plBipedInput01_flag0_activate)
{
gid01_event_type = gid01_event_scan_activate;
}
else // or passive scan?
{
gid01_event_type = gid01_event_scan_passive;
}
temp[0] = plBiped01_activate_scan_horz_width;
temp[1] = plBiped01_activate_scan_vert_width;
temp[2] = plBiped01_activate_scan_range;
//scan_entity(my.x,temp);
if(1 == cameraTarget_avatar_view_q )
{
// use camera center/facing
c_scan(cameraTarget_pos_vec.x,cameraTarget_ang_vec.pan,temp,IGNORE_ME | IGNORE_YOU | SCAN_ENTS | SCAN_LIMIT );
}
else
{
// use model center/facing
c_scan(my.x,my.pan,temp,IGNORE_ME | IGNORE_YOU | SCAN_ENTS | SCAN_LIMIT );
}

}


// Desc: handle player biped events
function PlBiped01_Event()
{

if((EVENT_TYPE == event_shoot) && (gid01_event_type == gid01_event_projectile_damage))
{
if(my._armor__003 > 0)
{
my._armor__003 -= gid01_event_value;

if(my._armor__003 < 0)
{
// flesh damage after armor damage
my._health__003 += my._armor__003;
my._armor__003 = 0;
PlBiped_Damage_Reaction(); // display damage panel
}
}
else
{ // take flesh damage
my._health__003 -= gid01_event_value;
PlBiped_Damage_Reaction(); // display damage panel
}
}

// handle scan events
if(EVENT_SCAN == EVENT_TYPE)
{
if(gid01_event_blast_damage == gid01_event_type)
{

// trace back to the blast source
if(1) // ++ fix c_trace(your.x,my.x,(ignore_me+ignore_you+ignore_passable+ignore_passents)) == 0)
{
if(my._armor__003 > 0)
{
my._armor__003 -= gid01_event_value;

if(my._armor__003 < 0)
{
// flesh damage after armor damage
my._health__003 += my._armor__003;
my._armor__003 = 0;
PlBiped_Damage_Reaction(); // display damage panel
}

}
else
{ // take flesh damage
my._health__003 -= gid01_event_value;
PlBiped_Damage_Reaction(); // display damage panel
}
}
}
}



// door/lift hit player
if((EVENT_TYPE == event_push))
{
if((gid01_event_type == gid01_event_push))
{
// alert "pusher" we got the event
you._gid01_message = 1; // send message back to door/lift


// take damage
my._health__003 -= gid01_event_value;
}
}


}

function Shield()
{
wait(2);

my.passable = on;
my.transparent = on;
my.red = 0;
my.green = 0;
my.blue = 255;
my.light = on;

you = my.parent;
vec_set(my.scale_x,you.scale_x);
vec_scale(my.scale_x,my.skill3);

var MaxEnergy;
MaxEnergy = my.skill1;

var Temp1;

while(you)
{
vec_set(my.x,you.x);
vec_set(my.pan,you.pan);

if(you.skill2 > 0){my.skill1 += min(my.skill1+you.skill2,MaxEnergy); you.skill2 = 0;}
if(you.skill1 < 100 && my.skill1 > 0)
{
my.alpha = my.skill2;
Temp1 = min(my.skill1,100-you.skill1);
my.skill1 -= Temp1;
you.skill1 += Temp1;
}
if(my.alpha > 0){my.alpha -= time_step;}

wait(1);
you = my.parent;
}
}

function Shield_Activate(ShieldEnergy,ShieldAlpha,ShieldScale)
{
you = ent_create("Modelname.mdl",nullvector,Shield); //<---------------------Change this!!!
you.parent = me;
you.skill1 = ShieldEnergy;
you.skill2 = ShieldAlpha;
you.skill3 = ShieldScale;
}

// ---------------------------------------------------------------------
// ACTIONS

///////////////////////////////////////////////////////////////////////
// Entity skill & flag definitions




// action: PlBiped01
// title: Biped (i.e. Human) Player Entity
// Desc: Action attached to the player entity
// Desc: Note: only valid if used once per level!
//
// uses _max_force_x__003, _max_force_y__003
// uses _max_ang_force_pan__003, _force_mult_003, _trigger_range__003
// uses _move_min_z__003, _jump_height__003, _duck_height__003
// uses _walkswim_dist__002, _runcrawl_dist__002, _standjump_time__002
// uses _attackduck_time__002, _deathdamage_time__002, _runthreshold__002
// uses _health__003, _armor__003, _no_fall_dam__003
//
//------------------
// section: Heath & Armor
// skill1: Health 100
// cntl: spin 1 x 5
// help: Reduced by damage. When <=0, player dies.
//
// skill2: Armor 0
// cntl: spin 0 x 5
// help: Reduces the damage that would otherwise be taken from health.
//
//------------------
// section: Movement
// skill3: ForceX 7.5
// help: Forward force used to calculate player speed.
// cntl: spin 0 x 0.25
//
// skill4: ForceY 3.75
// help: Force used to calculate player "side-step" speed.
// help: Also used for climbing and swimming up/down.
// cntl: spin 0 x 0.25
//
// skill6: Pan 10
// help: Force used to calculate the player's rotation speed.
// cntl: spin 0 x 0.25
//
// skill8: ForceMult 0.5
// help: Force multiplier when run/walk key is pressed:
/// > 1, player goes faster
/// < 1, player goes slower
// cntl: spin 0 x 0.25
//
//------------------
// section: Limits
//
// skill9: MinMoveZ 0.25
// help: Used to adjust the amount of upward sliding the player can do.
// help: 0-can slide up onto anything under half its height, 0.99 no upward sliding.
// cntl: spin 0 0.99 0.05
//
// skill10: Jump 75
// help: Height that the player tries to jump to.
// cntl: spin 0 x 1
//
// skill11: Duck 20
// help: How far the player can duck down.
// cntl: spin 0 x 1
//
// flag1: NoFallDamage 0
// help: If set, player takes no falling damage.
//
//------------------
// section: Animation
// skill12: WalkSwimDist 4.04
// help: Walk.Swim animation cycle distance.
// help: The value before the '.' calculates distance traveled to complete a walking cycle.
// help: The value after the '.' calculates distance traveled to complete a swimming cycle.
// cntl: spin 0 x 1
//
// skill13: RunCrawlDist 6.03
// help: Run.Crawl animation cycle distance.
// help: The value before the '.' calculates distance traveled to complete a run cycle.
// help: The value after the '.' calculates distance traveled to complete a crawling cycle.
// cntl: spin 0 x 1
//
// skill14: StandJumpTime 4.02
// help: Time in Stand.Jump animation cycle.
// cntl: spin 0 x 1
//
// skill15: AttackDuckTime 4.02
// help: Time in Attack.Duck animation cycle.
// cntl: spin 0 x 1
//
// skill16: DeathDamageTime 12.02
// help: Time in Death.Damage animation cycle.
// cntl: spin 0 x 1
//
// skill17: RunThreshold 12
// help: If player is moving faster then this many quants,
/// use running animation, otherwise use walking.
// cntl: spin 1 x 1
//
//------------------
// section: Misc.
// skill7: TriggerRange 25
// help: Used when the player tries to "trigger" something (i.e. pick up)
// cntl: spin 0 x 1
//
action PlBiped01
{
//watched = my; // uncomment to 'watch' the player
if(plBiped01_entity != 0)
{
diag("\nWARNING! PlBiped01::PlBiped01- Two or more PlBiped01 entities in level.");
wait(1); ent_remove(me);
return;
}

// setup for collision
wait(1);
BipedPhy01_Setup_Ent();

// upward glide
if(my._move_min_z__003 > 0.99)
{
my._move_min_z__003 = 0.99;
}
if(my._move_min_z__003 < 0)
{
my._move_min_z__003 = 0;
}


// set global player biped entity pointer to this object
plBiped01_entity = me;

// set id to player
my._gid01_id = gid01_player_const;

/////////////////////////////////////////////////////////////
// set up player specific variables (use defaults as needed)

// default health
if(my._health__003 == 0) { my._health__003 = 100; }
// default forces
if(my._max_force_x__003 == 0) { my._max_force_x__003 = 7.5; }
if(my._max_force_y__003 == 0) { my._max_force_y__003 = 3.75; }
if(my._max_ang_force_pan__003 == 0) { my._max_ang_force_pan__003 = 10.0; }
// default jump height
if(my._jump_height__003 == 0) { my._jump_height__003 = 75.0; }

// default animation values
if(my._walkswim_dist__002 == 0) // walk distance . swim distance
{
my._walkswim_dist__002 = 4.04;
}
if(my._runcrawl_dist__002 == 0) // run distance . crawl distance
{
my._runcrawl_dist__002 = 6.03;
}
if(my._standjump_time__002 == 0) // stand time . jump time
{
my._standjump_time__002 = 4.02;
}
if(my._attackduck_time__002 == 0) // attack time . duck time
{
my._attackduck_time__002 = 4.02;
}
if(my._deathdamage_time__002 == 0) // death time . damage time
{
my._deathdamage_time__002 = 12.02;
}
if(my._runthreshold__002 == 0) // run threshold
{
my._runthreshold__002 = 12;
}

if(my._trigger_range__003 == 0)
{
my.trigger_range = 5;
}
else
{
if(my._trigger_range__003 < 0) { my.trigger_range = 0; }
else { my.trigger_range = my._trigger_range__003; }
}


// set up event handler
my.event = PlBiped01_Event;
my.enable_shoot = on; // gun shoot
my.enable_scan = on; // explosions
my.enable_push = on; // stop/take damage from certain doors and platforms

// Call the biped setup function
PlBiped01_Init();

//Activate the shield
Shield_Activate(100,40,1.13); //<---------------------------Play around with these Values
// Shield_Activate(ShieldEnergy,ShieldAlpha,ShieldScale)

// Start the animation update loop (runs until biped is removed)
BipedAnim01_Update_Loop();
// Start the sound loop (runs until biped is removed)
BipedSnd01_Update_Loop();
}


endif;


Posted By: MadMark

Re: Script Factory - 05/06/07 01:11

Quote:

lol, try using the min_x/max_x for finding the size, and then add an offset to it.

offset = 100;
distance = (my.max_x - my.min_x)/2 + offset;

This will return the distance [radius] from the origin of the model to use...




xXxGuitar511 - Can you show me how to use it? RTFM is a fair answer, but if you think I haven't read the manual, I will send you a free hair sample!

Below is my spaghetti code that I was last using to overcome the issue, but alas, it is the source of my shiny scalp...

Apprecaite ANY help. This game is over 2 years old now, and was showing some real promise. To me, anyway.

Code:

function orbit_planet()
{
if (you != a_planet)
{
wait (1);
return;
}

else
{
player_switch = 2; //stop scanning until later
main_engine_temp = main_engine_status; //Store the engine status.
ship_speed_temp = ship_speed; // Store ship speed factor.
Main_engine_status = 0; // Engines offline in orbit.
ship_speed = 0;
info_txt.string = "ORBITTING PLANET!";
info_txt.visible = on; // Make it visible
waitt (16); // wait 1 seconds
info_txt.visible = off; // and make it invisible
info_txt.string = "Weapons systems disabled while in orbit.";
info_txt.visible = on; // Make it visible
snd_play (weapons_offline, 80, 0);
waitt (16); // wait 1 seconds
info_txt.string = "Hit 'O' to leave Orbit.";
info_txt.visible = on; // Make it visible
waitt (16); // wait 1 seconds
info_txt.visible = off; // and make it invisible

while(player_switch == 2) // While in orbit
{
vec_set(look_vec,you.x); //look at planet
vec_sub(look_vec,my.x); //look at planet
vec_to_angle(my.pan,look_vec); //look at planet
my.pan -= 60;
my.roll = -10;
my.x = you.x + cos(orbit_counter) * my.scan_distance;
my.y = you.y + sin(orbit_counter) * my.scan_distance;
orbit_counter += 1 * time; //orbit speed
wait (1);
orbit_menu_panel.visible = on;
enable_mouse = on;
mouse_mode = 2;
mouse_map = arrow_pcx;

if (key_O == 1)
{
snd_play (hail_sound, 80, 0); // Play the hail sound
info_txt.string = "Leaving Orbit.";
info_txt.visible = on; // Make it visible
waitt (32); // wait 1 seconds
info_txt.visible = off; // and make it invisible
player_switch = 3; // Transitional phase. Not in or out of orbit.
my.roll = 1; // Slight rotation.
my.pan = 0; // Straighten ship out.
move_mode = ignore_passable; // Yada yada yada
Main_engine_status == main_engine_temp; // Restore engine functions.
ship_speed = ship_speed_temp; // Restore speed.
ent_move(ship_speed, vec_to) - 500; // Break orbit far enough away to avoid re-orbit.
wait (1);
player_switch = 1; // Take ship to "not orbitting" status.
orbit_menu_panel.visible = off; // Get rid of the orbit menu.
mouse_mode = 1; // Turn mouse back to non-menu status.
mouse_map = null; // Lose the red arrow on Left mouse-click.
//enable_mouse = off; // Lose the mouse's normal behaviors.
}
}
}
}



Cheers!
Mark
Posted By: xXxGuitar511

Re: Script Factory - 05/06/07 01:43

...
my.roll = -10;
temp = (you.max_x - you.min_x)/2 + my.scan_distance;
my.x = you.x + cos(orbit_counter)*temp;
my.y = you.y + sin(orbit_counter)*temp;
orbit_counter += 1 * time;
...

Just add in the code in red...
Posted By: MadMark

Re: Script Factory - 05/06/07 02:08

You rock, my Guitar toting friend.
I will try it out tomorrow, if my grand daughter let's me escape the backyard.

Cheers,
Mark
Posted By: xXxGuitar511

Re: Script Factory - 05/06/07 02:57

ha, thankz man... lol.
Let us know if it works.

BTW: Just noting that this uses the entity's scan_distance skill for distance from the "planets" SURFACE. The closer the origin of the model is to the center, the better it will work. However, you can offset the origin for an offset orbit
Posted By: Blink

Re: Script Factory - 05/06/07 10:54

slin, i tried the code, no errors, but i think i must be doing something wrong. when my player is hit, the force bubble is supposed to appear and disappear, but its not doing it. am i forgetting something?
Posted By: Slin

Re: Script Factory - 05/06/07 10:58

Is the origin of the shield model in it´s center?
And is it the same for the playermodel?
Posted By: Blink

Re: Script Factory - 05/06/07 18:45

i think its centered. i have a question. this is what you put in the code.

Code:
  //Activate the shield	
Shield_Activate(100,40,1.13); //<---------------------------Play around with these Values
// Shield_Activate(ShieldEnergy,ShieldAlpha,ShieldScale)
// Start the animation update loop (runs until biped is removed)


is there supposed to be a comma after the 1 in the values instead of a period?
Posted By: Slin

Re: Script Factory - 05/06/07 18:50

No, it has to be a period.
But you could try a bigger value there. Like 2 or 3 instead of 1.13
Posted By: Blink

Re: Script Factory - 05/07/07 03:07

will increasing the value make the force field visible when i am hit?
Posted By: Blink

Re: Script Factory - 05/07/07 03:42

no, that didnt work at all.
Posted By: aslan123

Re: Script Factory - 05/07/07 10:14

hi would you be able to script me something

when my player looses his health i want him to be removed and start the level again only with 1 less life. is that possible
Posted By: Slin

Re: Script Factory - 05/07/07 12:45

@Blink: If you get shot, is the health keeping it´s startvalue? Is the shield model placed in your project folder?

@aslan123: Do you already have a playerscript? If you have, do you use the templates too, or do use an other one?
Posted By: Blink

Re: Script Factory - 05/07/07 16:13

Slin, the health value decreases normally when hit, so i know the code is working, but the shield doesnt appear when hit. also, i added the shield model is in the script. it shows up in the resouces in wed.
Posted By: aslan123

Re: Script Factory *DELETED* - 05/07/07 16:33

Post deleted by aslan123
Posted By: Locutus_of_Borg

Re: Script Factory - 05/08/07 09:43

I need a 1st person sword and bow&arrow script.
Weapon change should be on "q". Both weapons should aim with a crosshair and hit in the center of the crosshair. Bow should have 40 arrows as max ammo. I also need a ammo-pack for the bow. The damage of the sword should be 10 hp per hit and an arrow should do 30.

Thanks alot, if you can do this!

Use this as sword model: http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/742684/an/0/page/0#Post742684

And this as bow model:
http://www.matthias-schlich.de/bow.rar
Posted By: robertbruce

Bots vs bot script - 05/27/07 20:10

Hello,

Any chance of a simple AI that fights more then just the player, it fights other AIs

would be great

Rob
Posted By: Bahamut

Re: Bots vs bot script - 09/20/07 00:04

My request is very simple. I want a cool effect for changing levels. Like if you enter a battle in some RPG you see a cool effect, like a swirl eating the screen, or teh scren breakin in pieces, or some cool fading effect or blurr effect, i don't know, i want a cool effect and i don't know where to start.

It would be cool to have the screen going into a swirl, then that swirl making a sphere and that sphere dissapearing or exploding into the battle (or level or map).

Do you think that is possible?
Posted By: Nems

Re: Bots vs bot script - 09/20/07 00:10

Hi folks, you should post requests in the 'User Request' forum to get the responses your after.
Most people go directly to the threads that interest them first and many like to help but usually miss out because of mis posting.
OT.
Cool,just noticed the spell correction feature, no excuse for me now I guess.
© 2024 lite-C Forums