Most asked questions |
Top Previous Next |
Q: I'm using the sword combat wdl in Aum12 and I need help adding gravity to the player and enemy. Please help! A: Replace player_fight and enemy_fight with the ones below:
action player_fight // attached to the player { player = me; // I'm the player player.healthpoints = 100; // and I have 100 health points while (player.healthpoints > 0) // as long as I'm alive { camera.x = player.x - 200 * cos(player.pan); // 200 = distance between the player and the camera camera.y = player.y - 200 * sin(player.pan); // same value here camera.z = player.z + 200; // above the player camera.pan = player.pan; // looks in the same direction with the player camera.tilt = -30; // look down at the player
my.pan += 4 * (key_a - key_d) * time - 20 * mouse_force.x * time; // rotates with the keys A and D or with the mouse player_distance.x = 10 * (key_w - key_s) * time; // moves forward / backward with W / S player_distance.y = 0; vec_set (temp, my.x); temp.z -= 1000; trace_mode = ignore_me + use_box; player_distance.z = -trace (my.x, temp);
if ((key_w == 1) || (key_s == 1)) // the player is walking { ent_cycle("walk", my.skill20); // play walk frames animation my.skill20 += 4 * time; // "walk" animation speed if (my.skill20 > 100) {my.skill20 = 0;} // loop animation } else // the player is standing { ent_cycle("stand", my.skill21); // play stand frames animation my.skill21 += 2 * time; // "stand" animation speed if (my.skill21 > 100) {my.skill21 = 0;} // loop animation }
ent_move(player_distance, nullvector);
if (mouse_left == 1) // if we press the left mouse button { my.skill22 = 0; // reset "attack" frames while (my.skill22 < 100) { ent_vertex(my.sword_tip, 315); // sword tip vertex coords - get the value in Med ent_vertex(my.sword_base, 293); // sword base vertex coords - get the value in Med trace_mode = ignore_me + ignore_passable; // ignore me (the player) and all the entities that are passable trace (my.sword_base, my.sword_tip); // trace between these sword positions if (result != 0) // the player has hit something { effect (particle_sparks, 10, target, normal); if (you != null) {you.healthpoints -= 6 * time;} // if it hasn't hit a wall, decrease health ent_playsound (my, sword_snd, 50); // sword sound } ent_cycle("attack", my.skill22); // play attack frames animation my.skill22 += 8 * time; // "attack" animation speed wait (1); } while (mouse_left == 1) {wait (1);} // can't use autofire on a sword :) } wait (1); } while (my.skill23 < 90) // the player is dead { ent_cycle("death", my.skill23); // play death frames animation my.skill23 += 3 * time; // "death" animation speed wait (1); } my.passable = on; // the corpse can't be hit by the enemy sword from now on }
action enemy_fight // attached to the enemy { enemy = me; // I'm the enemy enemy.healthpoints = 100; // and I have 100 healthpoints while (my.healthpoints > 0) // as long as I'm alive { if (vec_dist (my.x, player.x) < 200 && player.healthpoints > 0) // the player approaches the enemy { vec_set(temp, player.x); vec_sub(temp, my.x); vec_to_angle(my.pan, temp); my.tilt = 0; // I'm a maniac :) enemy_distance.x = 5 * time; enemy_distance.y = 0; vec_set (temp, my.x); temp.z -= 1000; trace_mode = ignore_me + use_box; enemy_distance.z = -trace (my.x, temp); ent_move(enemy_distance, nullvector); ent_cycle("walk", my.skill19); // play walk frames animation my.skill19 += 5 * time; // "walk" animation speed if (my.skill19 > 100) {my.skill19 = 0;} // loop animation if (vec_dist (my.x, player.x) < 50) // if the player comes closer than 50 quants attack him { my.skill20 = 0; // reset "attack" frames while (my.skill20 < 100) { ent_vertex(my.sword_tip, 291); // sword tip vertex coords - get the value in Med ent_vertex(my.sword_base, 306); // sword base vertex coords - get the value in Med trace_mode = ignore_me + ignore_passable; trace (my.sword_base, my.sword_tip); // trace between these sword positions if (result != 0) // hit something, could be the player or another enemy { effect (particle_blood, 2, target, normal); if (you != null) {you.healthpoints -= 4 * time;} ent_playsound (my, sword_snd, 50); // sword sound } ent_cycle("attack", my.skill20); // play attack frames animation my.skill20 += 5 * time; // "attack" animation speed wait (1); } waitt (6); // slows down the enemy and reduces the number of traces per second } } else // the player is farther than 200 quants away { ent_cycle("stand", my.skill21); // play stand frames animation my.skill21 += 2 * time; // "stand" animation speed if (my.skill21 > 100) {my.skill21 = 0;} // loop animation } wait (1); } while (my.skill22 < 80) // the enemy is dead { ent_cycle("death", my.skill22); // play death frames animation my.skill22 += 1 * time; // "death" animation speed wait (1); } my.passable = on; // the corpse can't be hit by the sword from now on }
Q: How can I set the strength of the fog in my levels? I use camera.fog = 1..100 but I get the same effect. A: Use the new camera.fog_start and camera.fog_end to set the strength. Check "Fogger" in Aum25 to see an example.
Q: Can someone please explain how to make a movement similar to Counterstrike. As in normal walking is running and shift halves the speed. I'm using the templates. A: Place this line in function main:
shift_sense = 0.5;
and then change strength in movement.wdl like this:
var strength[3] = 10,4,75; // default ahead, side, jump strength
Q: I'm trying to program a block where you step on it and a door opens, but I don't want to handcode each door, so for each block I just want it to point to a door so I can open it and give it a generic function. Is this possible? A: Sure. Scan your doors using the block that triggers the event. Check the "Intelligent elevators" article in Aum18 to see how it is done.
Q: I have a gun and I can walk. If I fire a bullet I walk very slowly. Is this normal? A: No, it isn't normal. Your bullet collides with its creator - the gun. Add this line in front of the ent_move line that moves the bullet:
move_mode = ignore_you + ignore_passable
Q: How can I play AVIs on a sprite? A: Add the code below at the end of your office.wdl file; attach action movie_on_sprite to your sprite. Press "P" to play the movie.
action movie_on_sprite { while (key_p == 0) {wait (1);} // press "P" to play the movie media_play ("skiing.avi",bmap_for_entity (my, 0), 100); }
Q: Can anyone please tell me how to replace the sprite used by the rocket launcher with particles? A: Paste the code below at the beginning of weapons.wdl:
bmap spark_pcx = <spark.pcx>;
function fade_away() { my.alpha -= 3 * time; if (my.alpha < 0) {my.lifespan = 0;} }
function particle_sparks() { temp.x = random(2) - 1; temp.y = random(2) - 1; temp.z = random(2) - 1; vec_rotate (temp, my.pan); vec_normalize (temp, 3); vec_add (my.vel_x, temp); my.alpha = 40 + random(30); my.bmap = spark_pcx; my.size = random(2) + 5; my.flare = on; my.bright = on; my.move = on; my.lifespan = 100; my.function = fade_away; }
function _rocket_event2() { proc_kill(1); //EXCLUSIVE_ENTITY; // terminate other functions started by 'my' to stop moving MY.EVENT = NULL; MY.SKILL9 = -1; // stop movement
wait(1); // to avoid dangerous instruction in event warning // Apply damage range = MY._DAMAGE * 6; damage = MY._DAMAGE; temp.PAN = 360; temp.TILT = 360; temp.Z = range; indicator = _EXPLODE; // must always be set before scanning scan(MY.POS,MY_ANGLE,temp);
// Explode MY.AMBIENT = 100; MY.FACING = ON; MY.NEAR = ON; MY.FLARE = ON;
MY.PASSABLE = ON; MY.AMBIENT = 100; MY.LIGHTRED = light_flash.RED; MY.LIGHTGREEN = light_flash.GREEN; MY.LIGHTBLUE = light_flash.BLUE; MY.LIGHTRANGE = 64; wait(1);
play_entsound ME,hit_wham,300; my.skill9 = 10; vec_set (temp, my.pos); while (my.skill9 > 0) { effect (particle_sparks, 10, temp, normal); my.skill9 -= 2 * time; } remove(ME); }
and then edit two lines in function rocket_launch:
function rocket_launch() { vec_scale(MY.SCALE_X,actor_scale); // use actor_scale
MY.ENABLE_BLOCK = ON; // collision with map surface MY.ENABLE_ENTITY = ON; // collision with entity MY.ENABLE_STUCK = ON; MY.ENABLE_IMPACT = ON; MY.ENABLE_PUSH = ON; MY.EVENT = _rocket_event2;
MY.AMBIENT = 100; // bright MY.LIGHTRANGE = 150; MY.LIGHTRED = 250; MY.LIGHTGREEN = 50; MY.LIGHTBLUE = 50;
//- MY.PAN = YOUR.PAN; // the rocket start in the same direction than this 'emitter' //- MY.TILT = YOUR.TILT; //- MY.ROLL = YOUR.ROLL; vec_to_angle(MY.PAN, shot_speed);
MY.SKILL2 = shot_speed.x; MY.SKILL3 = shot_speed.y; MY.SKILL4 = shot_speed.z; MY._DAMAGE = damage; MY._FIREMODE = fire_mode;
MY.SKILL9 = 250; // 'burn time' (fuel) while(MY.SKILL9 > 0) { temp.X = MY.SKILL2 * TIME; temp.Y = MY.SKILL3 * TIME; temp.Z = MY.SKILL4 * TIME; vec_scale(temp,movement_scale); // scale distance by movement_scale //-- move(ME,NULLSKILL,temp); move_mode = ignore_you + ignore_passable + activate_trigger; result = ent_move(nullskill,temp);
emit(3,MY.POS,particle_smoke); // emit( smoke MY.SKILL9 -= TIME; // burn fuel wait(1); // update position once per tick } _rocket_event2(); // explode when out of fuel }
Q: Is there a way to change patrol_path so that it uses a 3D path? A: Use my "Campath" article in Aum6. That code moves the camera on a 3D path but you can replace the camera with any entity.
Q: I've seen people do some really incredible terrain with lod and grass etc. Just wondering if someone has the patience to share a clue with me. A: Unreal Tournament uses a simple LOD system for the grass, with detailed sprites that appear when the player gets closer. Serious Sam 2 creates a number of detailed grass sprites around the player and removes the ones that are far away from the player.
|