Character sounds, fixes to race position
Race position is still WIP, it screws up a lot around the finish line.pull/5/head
parent
5f89b4518b
commit
a468a7b189
|
@ -31,13 +31,19 @@ window.IngameRes = function(rom) {
|
||||||
"koura_w" /*blue shell item rep*/, "f_box", "killer" /*bullet bill*/
|
"koura_w" /*blue shell item rep*/, "f_box", "killer" /*bullet bill*/
|
||||||
]
|
]
|
||||||
|
|
||||||
|
//order
|
||||||
|
//donkey, toad, bowser?, luigi, mario, peach, wario, yoshi, daisy, waluigi, dry bones (karon), robo, heyho
|
||||||
|
var toSoundOff = [
|
||||||
|
4, 0, 1, 2, 5, 6, 7, 3, 10, 8, 9, 11, 12
|
||||||
|
];
|
||||||
|
|
||||||
var charNames = [
|
var charNames = [
|
||||||
"mario", "donkey", "kinopio", "koopa", "peach", "wario", "yoshi", "luigi", "karon", "daisy", "waluigi", "robo", "heyho"
|
"mario", "donkey", "kinopio", "koopa", "peach", "wario", "yoshi", "luigi", "karon", "daisy", "waluigi", "robo", "heyho"
|
||||||
]
|
];
|
||||||
|
|
||||||
var charAbbrv = [
|
var charAbbrv = [
|
||||||
"MR", "DK", "KO", "KP", "PC", "WR", "YS", "LG", "KA", "DS", "WL", "RB", "HH"
|
"MR", "DK", "KO", "KP", "PC", "WR", "YS", "LG", "KA", "DS", "WL", "RB", "HH"
|
||||||
]
|
];
|
||||||
|
|
||||||
var tireName = ["kart_tire_L", "kart_tire_M", "kart_tire_S"];
|
var tireName = ["kart_tire_L", "kart_tire_M", "kart_tire_S"];
|
||||||
|
|
||||||
|
@ -75,6 +81,7 @@ window.IngameRes = function(rom) {
|
||||||
loseA: new nsbca(r.KartModelSub.getFile(base+"_lose.nsbca")),
|
loseA: new nsbca(r.KartModelSub.getFile(base+"_lose.nsbca")),
|
||||||
spinA: new nsbca(r.KartModelSub.getFile(base+"_spin.nsbca")),
|
spinA: new nsbca(r.KartModelSub.getFile(base+"_spin.nsbca")),
|
||||||
winA: new nsbca(r.KartModelSub.getFile(base+"_win.nsbca")),
|
winA: new nsbca(r.KartModelSub.getFile(base+"_win.nsbca")),
|
||||||
|
sndOff: toSoundOff[ind]*14,
|
||||||
}
|
}
|
||||||
characters[ind] = obj;
|
characters[ind] = obj;
|
||||||
return characters[ind];
|
return characters[ind];
|
||||||
|
|
|
@ -165,6 +165,11 @@ window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes)
|
||||||
vec3.scale(targ, targ, 1/1024);
|
vec3.scale(targ, targ, 1/1024);
|
||||||
mat4.mul(scn.shadMat, mat4.ortho(mat4.create(), targ[0]-shadres, targ[0]+shadres, targ[1]-shadres, targ[1]+shadres, -targ[2]-2.5, -targ[2]+2.5), scn.lightMat);
|
mat4.mul(scn.shadMat, mat4.ortho(mat4.create(), targ[0]-shadres, targ[0]+shadres, targ[1]-shadres, targ[1]+shadres, -targ[2]-2.5, -targ[2]+2.5), scn.lightMat);
|
||||||
|
|
||||||
|
var places = [];
|
||||||
|
for (var i=0; i<scn.karts.length; i++) { places.push(scn.karts[i]); }
|
||||||
|
places.sort(function(a, b) {return b.getPosition() - a.getPosition()});
|
||||||
|
for (var i=0; i<places.length; i++) { places[i].placement = i+1; };
|
||||||
|
|
||||||
for (var i=0; i<scn.karts.length; i++) {
|
for (var i=0; i<scn.karts.length; i++) {
|
||||||
var ent = scn.karts[i];
|
var ent = scn.karts[i];
|
||||||
if (ent.active) ent.update(scn);
|
if (ent.active) ent.update(scn);
|
||||||
|
@ -291,9 +296,9 @@ window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes)
|
||||||
// the thresholds for different win sounds and music
|
// the thresholds for different win sounds and music
|
||||||
// thresh, goalsound, goalmusic, goalpostmusic
|
// thresh, goalsound, goalmusic, goalpostmusic
|
||||||
var finishPercents = [
|
var finishPercents = [
|
||||||
[0, 66, 46, 58],
|
[0, 66, 46, 58, 9],
|
||||||
[0.5, 66, 47, 56],
|
[0.5, 66, 47, 56, 10],
|
||||||
[1.1, 67, 48, 57]
|
[1.1, 67, 48, 57, 11]
|
||||||
]
|
]
|
||||||
|
|
||||||
function lapAdvance(kart) {
|
function lapAdvance(kart) {
|
||||||
|
@ -309,20 +314,21 @@ window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes)
|
||||||
else if (kart.lapNumber == 4) {
|
else if (kart.lapNumber == 4) {
|
||||||
var finishTuple = [];
|
var finishTuple = [];
|
||||||
for (var i=0; i<finishPercents.length; i++) {
|
for (var i=0; i<finishPercents.length; i++) {
|
||||||
if (finishPercents[i][0] > winPercent) continue;
|
|
||||||
finishTuple = finishPercents[i];
|
finishTuple = finishPercents[i];
|
||||||
|
if (finishPercents[i][0] >= winPercent) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
kart.controller = new controlRaceCPU(scn.nkm, {});
|
kart.controller = new controlRaceCPU(scn.nkm, {});
|
||||||
kart.controller.setKart(kart);
|
kart.controller.setKart(kart);
|
||||||
|
|
||||||
kart.anim.setAnim(winPercent>0.5?kart.charRes.LoseA:kart.charRes.winA);
|
kart.anim.setAnim(winPercent>0.5?kart.charRes.loseA:kart.charRes.winA);
|
||||||
kart.animMode = "raceEnd";
|
kart.animMode = "raceEnd";
|
||||||
|
|
||||||
scn.camera = (new cameraSpectator(kart, scn));
|
scn.camera = (new cameraSpectator(kart, scn));
|
||||||
nitroAudio.playSound(finishTuple[1], {volume:2}, 0);
|
nitroAudio.playSound(finishTuple[1], {volume:2}, 0);
|
||||||
nitroAudio.playSound(finishTuple[2], {volume:2}, null);
|
nitroAudio.playSound(finishTuple[2], {volume:2}, null);
|
||||||
nitroAudio.instaKill(scn.musicPlayer);
|
nitroAudio.instaKill(scn.musicPlayer);
|
||||||
|
kart.playCharacterSound(finishTuple[4], 2);
|
||||||
musicRestartTimer = 0;
|
musicRestartTimer = 0;
|
||||||
musicRestart = 7.5*60;
|
musicRestart = 7.5*60;
|
||||||
musicRestartType = 1;
|
musicRestartType = 1;
|
||||||
|
|
|
@ -21,6 +21,7 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
|
|
||||||
var params = scene.gameRes.kartPhys.karts[kartN];
|
var params = scene.gameRes.kartPhys.karts[kartN];
|
||||||
var offsets = scene.gameRes.kartOff.karts[kartN];
|
var offsets = scene.gameRes.kartOff.karts[kartN];
|
||||||
|
this.wheelClass = (offsets.name[10] == "L")?2:((offsets.name[10] == "M")?1:0);
|
||||||
|
|
||||||
this.local = controller.local;
|
this.local = controller.local;
|
||||||
this.active = true;
|
this.active = true;
|
||||||
|
@ -66,6 +67,9 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
this.drawWheels = drawWheels;
|
this.drawWheels = drawWheels;
|
||||||
this.drawChar = drawChar;
|
this.drawChar = drawChar;
|
||||||
|
|
||||||
|
this.getPosition = getPosition;
|
||||||
|
this.playCharacterSound = playCharacterSound;
|
||||||
|
|
||||||
this.trackAttach = null; //a normal for the kart to attach to (loop)
|
this.trackAttach = null; //a normal for the kart to attach to (loop)
|
||||||
this.boostMT = 0;
|
this.boostMT = 0;
|
||||||
this.boostNorm = 0;
|
this.boostNorm = 0;
|
||||||
|
@ -73,6 +77,10 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
this.kartColVel = vec3.create();
|
this.kartColVel = vec3.create();
|
||||||
this.kartColTimer = 0;
|
this.kartColTimer = 0;
|
||||||
this.kartWallTimer = 0;
|
this.kartWallTimer = 0;
|
||||||
|
this.charSoundTimer = 0;
|
||||||
|
|
||||||
|
this.placement = 0;
|
||||||
|
this.lastPlacement = 0;
|
||||||
|
|
||||||
var charRes = scene.gameRes.getChar(charN);
|
var charRes = scene.gameRes.getChar(charN);
|
||||||
var kartRes = scene.gameRes.getKart(kartN);
|
var kartRes = scene.gameRes.getKart(kartN);
|
||||||
|
@ -206,7 +214,7 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
mat4.rotateX(wmat, wmat, wheelTurn);
|
mat4.rotateX(wmat, wmat, wheelTurn);
|
||||||
|
|
||||||
if (i>1) {
|
if (i>1) {
|
||||||
k.wheelParticles[i-2].offset = vec3.scale(k.wheelParticles[i-2].offset, vec3.add(k.wheelParticles[i-2].offset, offsets.wheels[i], [0, -params.colRadius, 0]), 1/16);
|
k.wheelParticles[i-2].offset = vec3.scale(k.wheelParticles[i-2].offset, vec3.add(k.wheelParticles[i-2].offset, offsets.wheels[i], [k.wheelClass*(i-2.5)*-2, (-params.colRadius)-k.wheelClass*2, 0]), 1/16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +289,15 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
k.lWheelParticle = null;
|
k.lWheelParticle = null;
|
||||||
|
|
||||||
function update(scene) {
|
function update(scene) {
|
||||||
|
if (k.placement != k.lastPlacement) {
|
||||||
|
if (k.placement < k.lastPlacement) {
|
||||||
|
if (k.charSoundTimer == 0) {
|
||||||
|
playCharacterSound(5);
|
||||||
|
k.charSoundTimer = 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
k.lastPlacement = k.placement;
|
||||||
|
}
|
||||||
|
|
||||||
var lastPos = vec3.clone(k.pos);
|
var lastPos = vec3.clone(k.pos);
|
||||||
updateMat = true;
|
updateMat = true;
|
||||||
|
@ -406,6 +423,7 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
} else { //default kart mode
|
} else { //default kart mode
|
||||||
|
|
||||||
if (k.OOB > 0) {
|
if (k.OOB > 0) {
|
||||||
|
playCharacterSound(0);
|
||||||
var current = checkpoints[k.checkPointNumber];
|
var current = checkpoints[k.checkPointNumber];
|
||||||
var respawn = respawns[current.respawn];
|
var respawn = respawns[current.respawn];
|
||||||
k.physicalDir = (180-respawn.angle[1])*(Math.PI/180);
|
k.physicalDir = (180-respawn.angle[1])*(Math.PI/180);
|
||||||
|
@ -413,6 +431,7 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
k.speed = 0;
|
k.speed = 0;
|
||||||
k.vel = vec3.create();
|
k.vel = vec3.create();
|
||||||
k.pos = vec3.clone(respawn.pos);
|
k.pos = vec3.clone(respawn.pos);
|
||||||
|
vec3.add(k.pos, k.pos, [0,16,0]);
|
||||||
if (k.controller.setRouteID != null) k.controller.setRouteID(respawn.id1);
|
if (k.controller.setRouteID != null) k.controller.setRouteID(respawn.id1);
|
||||||
k.OOB = 0;
|
k.OOB = 0;
|
||||||
}
|
}
|
||||||
|
@ -645,6 +664,7 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
|
|
||||||
if (k.kartColTimer > 0) k.kartColTimer--;
|
if (k.kartColTimer > 0) k.kartColTimer--;
|
||||||
if (k.kartWallTimer > 0) k.kartWallTimer--;
|
if (k.kartWallTimer > 0) k.kartWallTimer--;
|
||||||
|
if (k.charSoundTimer > 0) k.charSoundTimer--;
|
||||||
|
|
||||||
wheelTurn += k.speed/16;
|
wheelTurn += k.speed/16;
|
||||||
wheelTurn = fixDir(wheelTurn);
|
wheelTurn = fixDir(wheelTurn);
|
||||||
|
@ -714,8 +734,27 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
positionChanged(lastPos, k.pos);
|
positionChanged(lastPos, k.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function playCharacterSound(sound, volume) {
|
||||||
|
//0 - hit
|
||||||
|
//1 - hit spin
|
||||||
|
//2 - hit ?? hit grnd
|
||||||
|
//3 - hit banana? race start?
|
||||||
|
//4 - hit spin?
|
||||||
|
//5 - good pass?
|
||||||
|
//6 - good OK!
|
||||||
|
//7 - use item
|
||||||
|
//8 - hit someone?
|
||||||
|
//9 = win
|
||||||
|
//10 = alright
|
||||||
|
//11 = bad
|
||||||
|
//12 = good record
|
||||||
|
//13 = bad record
|
||||||
|
if (volume == null) volume = 1;
|
||||||
|
nitroAudio.playSound(sound + charRes.sndOff, {volume: 2*volume}, 2, k);
|
||||||
|
}
|
||||||
|
|
||||||
function clearWheelParticles(prio) {
|
function clearWheelParticles(prio) {
|
||||||
for (let i=0; i<2; i++) {
|
for (var i=0; i<2; i++) {
|
||||||
if (prio == null) {
|
if (prio == null) {
|
||||||
//clear all specials
|
//clear all specials
|
||||||
k.wheelParticles[i].clearEmitter(1); //drift mode
|
k.wheelParticles[i].clearEmitter(1); //drift mode
|
||||||
|
@ -727,7 +766,7 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWheelParticles(id, prio) {
|
function setWheelParticles(id, prio) {
|
||||||
for (let i=0; i<2; i++) {
|
for (var i=0; i<2; i++) {
|
||||||
k.wheelParticles[i].setEmitter(id, prio);
|
k.wheelParticles[i].setEmitter(id, prio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,6 +821,15 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPosition() {
|
||||||
|
if (futureChecks.length == 0) return 0;
|
||||||
|
var check = checkpoints[futureChecks[0]];
|
||||||
|
var dist = vec2.sub([], [check.x1, check.z1], [k.pos[0], k.pos[2]]);
|
||||||
|
var dot = vec2.dot(dist, [check.sinus, check.cosinus]);
|
||||||
|
|
||||||
|
return k.checkPointNumber + (1-(Math.abs(dot)/(0xFFFF))) + k.lapNumber*checkpoints.length;
|
||||||
|
}
|
||||||
|
|
||||||
function forwardCrossedKTP(ktp, oldPos, pos) {
|
function forwardCrossedKTP(ktp, oldPos, pos) {
|
||||||
var distOld = vec2.sub([], [ktp.pos[0], ktp.pos[2]], [oldPos[0], oldPos[2]]);
|
var distOld = vec2.sub([], [ktp.pos[0], ktp.pos[2]], [oldPos[0], oldPos[2]]);
|
||||||
var dist = vec2.sub([], [ktp.pos[0], ktp.pos[2]], [pos[0], pos[2]]);
|
var dist = vec2.sub([], [ktp.pos[0], ktp.pos[2]], [pos[0], pos[2]]);
|
||||||
|
@ -1039,7 +1087,7 @@ window.Kart = function(pos, angle, speed, kartN, charN, controller, scene) {
|
||||||
else
|
else
|
||||||
setWheelParticles(particle, 0);
|
setWheelParticles(particle, 0);
|
||||||
}
|
}
|
||||||
if (!onGround) {
|
if (!onGround && !stick) {
|
||||||
groundAnim = 0;
|
groundAnim = 0;
|
||||||
if (lastColSounds.land != null) nitroAudio.playSound(lastColSounds.land, {volume:1}, 0, k)
|
if (lastColSounds.land != null) nitroAudio.playSound(lastColSounds.land, {volume:1}, 0, k)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue