2 registered members (VoroneTZ, TipmyPip),
1,333
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Script Factory
[Re: Blink]
#127670
05/04/07 23:02
05/04/07 23:02
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
OP
Expert
|
OP
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
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...).
|
|
|
Re: Script Factory
[Re: Blink]
#127671
05/04/07 23:03
05/04/07 23:03
|
Joined: Jan 2006
Posts: 2,157 Connecticut, USA
Blink
Expert
|
Expert
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
|
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;
My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
|
|
|
Re: Script Factory
[Re: Slin]
#127673
05/05/07 07:32
05/05/07 07:32
|
Joined: Jan 2006
Posts: 2,157 Connecticut, USA
Blink
Expert
|
Expert
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
|
it didnt change at all, still no force field.
My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
|
|
|
Re: Script Factory
[Re: Blink]
#127674
05/05/07 22:58
05/05/07 22:58
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
OP
Expert
|
OP
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
@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;
|
|
|
Re: Script Factory
[Re: xXxGuitar511]
#127675
05/06/07 01:11
05/06/07 01:11
|
Joined: Aug 2002
Posts: 572 Toronto
MadMark
User
|
User
Joined: Aug 2002
Posts: 572
Toronto
|
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
People who live in glass houses shouldn't vacuum naked.
|
|
|
Re: Script Factory
[Re: MadMark]
#127676
05/06/07 01:43
05/06/07 01:43
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
... 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...
xXxGuitar511 - Programmer
|
|
|
Re: Script Factory
[Re: xXxGuitar511]
#127677
05/06/07 02:08
05/06/07 02:08
|
Joined: Aug 2002
Posts: 572 Toronto
MadMark
User
|
User
Joined: Aug 2002
Posts: 572
Toronto
|
You rock, my Guitar toting friend. I will try it out tomorrow, if my grand daughter let's me escape the backyard.
Cheers, Mark
People who live in glass houses shouldn't vacuum naked.
|
|
|
Re: Script Factory
[Re: MadMark]
#127678
05/06/07 02:57
05/06/07 02:57
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
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
xXxGuitar511 - Programmer
|
|
|
Re: Script Factory
[Re: xXxGuitar511]
#127679
05/06/07 10:54
05/06/07 10:54
|
Joined: Jan 2006
Posts: 2,157 Connecticut, USA
Blink
Expert
|
Expert
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
|
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?
My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
|
|
|
|