This is 'your' thread.
If issue feedback is / was desired, a separate thread would have been more appropriate.

There are three parts (files):


rsr1.wdl
Code:
font standard_font = <ackfont.pcx>, 6, 9; // panel font
/*******************************
	images
*******************************/
bmap imSpark = <spkpart.pcx>;			// for spark particles
bmap imBlood = <bloodspray.pcx>;  // for blood particles
/*******************************
	sounds
*******************************/
sound sdBeep = <msg.wav>;
sound sdSword = <knife.wav>;

/*******************************
levels
*******************************/
STRING lvl_s1 =  <testswordlvl1.wmb>;	// level string


sword-fight.wdl
Code:
/*
sword-fight.wdl
2008.08.15
tD
pseudo-auto generated from src: Blink
---trimmed!?
---made more flexible!?
---but no additional functionality added;
*/

/*******************************
	skills
*******************************/
define _wpBase, skill12; 	// vertex sword base (override)
define _wpTip, skill15; 	// vertex sword tip (override)
define _hp, skill18;			// hit points
define _st1, skill21;
define _anip, skill23;		// ani percent
define _atkTm, skill24;		// not active, gave problems

/*******************************
	animation strings
*******************************/

var _STAND = 0;
var _WALK = 1;
var _ATK1 = 2;
var _DEAD = 3;

// for dummies (comment these out)
TEXT ani_t1 {
	strings = 4;
	string = "standB";
	string = "walkA";
	string = "slashR";
	string = "dieA";
}
// below are the original ani strings
// uncomment these
/*
TEXT ani_t1 {
	strings  = 4;
	string = "stand";
	string = "walk";
	string = "attack";
	string = "death";
}*/
var ani_nSpAtk = 5;		// ani sp attack
var ani_nSpDie = 3;		// ani sp die
var ani_nSpStand = 2;	// ani sp stand
var ani_nSpWalk = 4;	// ani sp walk




var pl_vDist[3]; // moves the player
var pl_nHpD = 100;

string hp_s1 = "STRENGTH: ";		// hitpoints string


/*******************************
	ai
*******************************/
ENTITY* ai_e1; 			//  
var ai_vDist[3]; // moves the enemy

var ai_nAlertDist = 5;	// alert distance; multiple of entity size x
var ai_nAtkDist = 1.5;	// attack distance; multiple of entity size x
var ai_nHpD = 20;				// default enemy hit points
/*******************************
	weapon
*******************************/
// originals; uncomment these
//var wp_nBaseD = 601;	// vertex sword base default
//var wp_nTipD = 5;			// vertex sword tip default

// for dummies; comment these out
var wp_nBaseD = 138;
var wp_nTipD = 145;


var wp_nResult = 0;				// a temp for wp trace result
var wp_nSwordDamage = 10;	// sword damage multiplier


panel hp_p1 {  // sux compared to alternatives
	pos_x = 0;
	pos_y = 0;
	digits =120, 575, 4, standard_font, 1, player._hp;
	flags = refresh, visible;
}

text hp_t1 { 	// sux compared to alternatives
	pos_x = 30;
	pos_y = 550;
	font = standard_font;
	string = hp_s1;
	flags = visible;
}


/*******************************
	temps
*******************************/
var v1[3];
var v2[3];



/*******************************
	function prototypes
*******************************/
function particle_sparks();
function particle_blood();
function fade_particle();


/*******************************
	cam3f_1
		camera 3rd person function 
		player only for now
*******************************/
function cam3f_1() {
	// camera
	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 + 50; // above the player
	camera.pan = player.pan; // looks in the same direction with the player
	camera.tilt = -10; // look down at the player
}
/*******************************
	plf_input
		player input function
*******************************/
function plf_input() {
	my.pan += -20 * mouse_force.x * time_step; // rotates with the mouse
	pl_vDist.x = 10 * ((key_w || key_cuu) - (key_s || key_cud)) * time_step; // moves forward / backward with W / S
	pl_vDist.y = 5 * ((key_a || key_cul) - (key_d || key_cur)) * time_step; // move side to side
	pl_vDist.z = 0;
}
/*******************************
zotf_ani
	zot ~= actor
*******************************/
function zotf_ani(_nAniSp, _bLoop) {
	ent_animate(me, ani_t1.string[my._st1], my._anip, ANM_CYCLE);
	my._anip += _nAniSp;
	if (_bLoop) {
		my._anip %= 100;
		return(0); 
	} else {
		my._anip = min(my._anip, 100);
	}
	if (my._anip >= 100) {
		return(100);
	}
}
/*******************************
	zotf_die
*******************************/
function zotf_die() {
	zotf_st(_DEAD);
	while (my._anip < 90) { // the player is dead
		zotf_ani(ani_nSpDie, 0);
		wait (1);
	}
	my.passable = ON; // the corpse can't be hit by the enemy sword from now on
}
/*******************************
	zotf_st
		reset ani on state change
*******************************/
function zotf_st(_st) {
	if (my._st1 == _st) {
		return(0);
	}
	my._st1 = _st;
	my._anip = 0;
	return(1);
}
/*******************************
	zotf_new
*******************************/
function zotf_new() {
	c_setminmax(me);
	wait(1);
	my._wpBase = wp_nBaseD;
	my._wpTip = wp_nTipD;
}
/*******************************
	wpf_trace
		weapon trace function
*******************************/
function wpf_trace() {
	vec_for_vertex(v1, ME, my._wpBase); // sword tip vertex coords - get the value in Med
	vec_for_vertex(v2, ME, my._wpTip); // 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
	wp_nResult = trace(v1, v2); // trace between these sword positions

	if (wp_nResult != 0) { // the player has hit something
		effect (particle_sparks, 10, target, normal);
		if (you != null) {you._hp -= wp_nSwordDamage * time_step;} // if it hasn't hit a wall, decrease health
			ent_playsound (me, sdSword, 500); // sword sound
		}
	}
}
/*******************************
	player_fight
		pl_a1
		player action
*******************************/
action player_fight { // attached to the player
	player = ME; // I'm the player
	player._hp = pl_nHpD; // and I have 100 health points
	zotf_new();
	while (ME != NULL) { // as long as I'm alive
		if (my._hp <= 0) { break; }
		plf_input();
		//move
		cam3f_1();

		
		var pl_bWalk; pl_bWalk = (abs(pl_vDist.x) > 0) || (abs(pl_vDist.y) > 0); 
		if (pl_bWalk) { // the player is walking
			zotf_st(_WALK);
			zotf_ani(ani_nSpWalk, 1);
		} else {  // not walking
			zotf_st(_STAND);
			zotf_ani(ani_nSpStand, 1);
		}
		ent_move(pl_vDist, nullvector);

		if (mouse_left) {// if we press the left mouse button
			zotf_st(_ATK1);
			while (my._anip < 100) {
			
				zotf_ani(ani_nSpAtk, 0);
				wpf_trace();
				wait (1);
			}
			//k_st[k_ml] = !mouse_left; // can't use autofire on a sword
		}
		str_for_num(hp_s1, my._hp);
		wait (1);
	}
	zotf_die();

}

/*******************************
	enemy_fight
		ai_a1
		enemy / ai action
*******************************/
action enemy_fight { // attached to the enemy
	ai_e1 = me; // I'm the enemy
	ai_e1._hp = ai_nHpD; // and I have 100 _hp
	zotf_new();
	while (ME != NULL)  { // as long as I'm alive
		if (my._hp <= 0) { break; }
		if ((vec_dist (my.x, player.x) < ((my.max_x - my.min_x) * ai_nAlertDist))
		 && player._hp > 0)  {// the player approaches the enemy
			vec_diff(temp, player.x, my.x);
			vec_to_angle(my.pan, temp);
			my.tilt = 0; // I'm a maniac
			
			ai_vDist.x = 5 * time_step;
			ai_vDist.y = 0;
			ai_vDist.z = 0;
			zotf_st(_WALK);
			ent_move(ai_vDist, nullvector);
			zotf_ani(ani_nSpWalk, 1);
			if (vec_dist (my.x, player.x) < (my.max_x * ai_nAtkDist)) { // if the player comes closer than 50 quants attack him 
				zotf_st(_ATK1);
				while (my._anip < 100){
					//if (my._atkTm <= 0) {
						wpf_trace();
						//my._atkTm = 16 * 6;
					//}
					zotf_ani(ani_nSpAtk, 0);
					wait (1);
				}
			}

		} else { // the player is farther than 200 quants away
			zotf_st(_STAND);
			zotf_ani(ani_nSpStand, 1);
		}
		wait (1);
	}
	zotf_die();
}
function particle_sparks() {
	temp.x = random(2) - 1;
	temp.y = random(2) - 1;
	temp.z = random(1) - 1.5;
	vec_add (my.vel_x, temp);
	my.alpha = 30 + random(50);
	my.bmap = imSpark;
	my.size = 5;
	my.flare = on;
	my.bright = on;
	my.move = on;
	my.lifespan = 20;
	my.function = fade_particle;
	my.gravity =0;
	my.beam = on;
	my.streak = on;
}
function particle_blood() {
	temp.x = random(2) - 1;
	temp.y = random(2) - 1;
	temp.z = random(1) - 1.5;
	vec_add (my.vel_x, temp);
	my.alpha = 70 + random(30);
	my.bmap = imBlood;
	my.size = 6;
	my.flare = on;
	my.bright = on;
	my.move = on;
	my.lifespan = 20;
	my.function = fade_particle;
}

function fade_particle() {
	my.alpha -= 5 * time_step;
	if (my.alpha < 0) {my.lifespan = 0;}
}


main1.wdl
Code:

path "images";
path "models";
path "sounds";


include <rsr1.wdl>;
include <sword-fight.wdl>;


var video_mode = 7; // 800x600
var video_depth = 32; // 16 bit mode


function main() {
	level_load(lvl_s1);
	wait(2); // wait for the level to be loaded
	clip_size = 0; // show all the triangles for all the models
	on_d = null; // disable the debug panel (key "D") because it is used for movement
	fps_max = 40; // lock the frame rate to 40 fps
	wait(1);
}


see comments.
Right about now would be a good time to complain about browser-specific code text box copy-n-paste functionality!?