content/hifi-content/jedon/Game_Creater_Toolkit/SAO/SAO_Arena_Resetter.js
2022-02-13 23:57:50 +01:00

293 lines
No EOL
10 KiB
JavaScript

(function() {
var _this = this;
//hold id's of swords
var sword1;
var sword2;
//positions and rotations of swords should be on reset
var swordPos1;
var swordPos2;
var swordRot;
_this.preload = function (entityID) {
print("Loading reset script");
this.entityID = entityID;
};
_this.startFarTrigger = function()
{
print("Resetting arena");
//get sword id's and positions
var props = Entities.getEntityProperties(this.entityID);
var properties = JSON.parse(props.userData);
sword1 = properties.sword1ID;
sword2 = properties.sword2ID;
swordPos1 = properties.swordPosition1;
swordPos2 = properties.swordPosition2;
swordRot = properties.swordRotation;
//delete old sword
Entities.deleteEntity(sword1);
//cretae new sword
var newSwordProp1 = {
"type": "Model", //changed to Model when fixed
"lifetime": -1,
"position": swordPos1,
"collisionless": false,
"collidesWith": "static",
"rotation": swordRot,
"dynamic": true, //maybe change back to true
"damping": .9,
"angularDamping": .9,
//"visible": false, //changed for testing
userData: JSON.stringify({
grabbableKey: {
grabbable: false,
ignoreIK: false
},
equipHotspots: [{
position: {x: 0.11031082272529602, y: -0.13449540972709656, z: 0.0405043363571167},
radius: 0.25,
joints: { //x and y .15 increase
RightHand: [
{x: 0.26031082272529602, y: 0.31449540972709656, z: 0.0405043363571167},
rotateSwordRight()
],
LeftHand: [
{x: -0.25801754891872406, y: 0.30447449684143066, z: 0.030637264251708984},
rotateSwordLeft()
]
},
modelURL: 'http://hifi-content.s3.amazonaws.com/alan/dev/equip-Fresnel-3.fbx',
modelScale: {
x: 1,
y: 1,
z: 1
}
}],
"noGear": true
}),
name: "ROC-Sword",
modelURL: "https://hifi-content.s3.amazonaws.com/jedon/Assets/broadsword_01.fbx",
shapeType: "compound",
script: "https://hifi-content.s3.amazonaws.com/jedon/Game_Creater_Toolkit/SAO/SAO_Battle_Simulator.js?" + Date.now()
//script: "C:/Users/0425-DESKTOP-PC/Downloads/SAO_Battle_Simulator.js"
};
var newSword1 = Entities.addEntity(newSwordProp1);
//delete old sword
Entities.deleteEntity(sword2);
//cretae new sword
var newSwordProp2 = {
"type": "Model", //changed to Model when fixed
"lifetime": -1,
"position": swordPos2,
"collisionless": false,
"collidesWith": "static",
"rotation": swordRot,
"dynamic": true, //maybe change back to true
"damping": .9,
"angularDamping": .9,
//"visible": false, //changed for testing
userData: JSON.stringify({
grabbableKey: {
grabbable: false,
ignoreIK: false
},
equipHotspots: [{
position: {x: 0.11031082272529602, y: -0.13449540972709656, z: 0.0405043363571167},
radius: 0.25,
joints: { //x and y .15 increase
RightHand: [
{x: 0.26031082272529602, y: 0.31449540972709656, z: 0.0405043363571167},
rotateSwordRight()
],
LeftHand: [
{x: -0.25801754891872406, y: 0.30447449684143066, z: 0.030637264251708984},
rotateSwordLeft()
]
},
modelURL: 'http://hifi-content.s3.amazonaws.com/alan/dev/equip-Fresnel-3.fbx',
modelScale: {
x: 1,
y: 1,
z: 1
}
}],
"noGear": true
}),
name: "ROC-Sword",
modelURL: "https://hifi-content.s3.amazonaws.com/jedon/Assets/broadsword_01.fbx",
shapeType: "compound",
script: "https://hifi-content.s3.amazonaws.com/jedon/Game_Creater_Toolkit/SAO/SAO_Battle_Simulator.js?" + Date.now()
//script: "C:/Users/0425-DESKTOP-PC/Downloads/SAO_Battle_Simulator.js"
};
var newSword2 = Entities.addEntity(newSwordProp2);
//delete everything that came with the old swords (hearts, shields, etc)
Entities.callEntityMethod(sword1, "resetArena");
Entities.callEntityMethod(sword2, "resetArena");
//place new sword id's in sign
var newSignProp = {
grabbableKey: {
grabbable: false,
ignoreIK: false,
wantsTrigger: true
},
"sword1ID": newSword1,
"sword2ID": newSword2,
"swordPosition1": swordPos1,
"swordPosition2": swordPos2,
"swordRotation": swordRot
};
//send to sign
Entities.editEntity(this.entityID, { userData: JSON.stringify(newSignProp) });
};
_this.startNearTrigger = function()
{
print("Resetting arena");
//get sword id's and positions
var props = Entities.getEntityProperties(this.entityID);
var properties = JSON.parse(props.userData);
sword1 = properties.sword1ID;
sword2 = properties.sword2ID;
swordPos1 = properties.swordPosition1;
swordPos2 = properties.swordPosition2;
swordRot = properties.swordRotation;
//delete old sword
Entities.deleteEntity(sword1);
//cretae new sword
var newSwordProp1 = {
"type": "Model", //changed to Model when fixed
"lifetime": -1,
"position": swordPos1,
"collisionless": false,
"collidesWith": "static",
"rotation": swordRot,
"dynamic": true, //maybe change back to true
"damping": .9,
"angularDamping": .9,
//"visible": false, //changed for testing
userData: JSON.stringify({
grabbableKey: {
grabbable: false,
ignoreIK: false
},
equipHotspots: [{
position: {x: 0.11031082272529602, y: -0.13449540972709656, z: 0.0405043363571167},
radius: 0.25,
joints: { //x and y .15 increase
RightHand: [
{x: 0.26031082272529602, y: 0.31449540972709656, z: 0.0405043363571167},
rotateSwordRight()
],
LeftHand: [
{x: -0.25801754891872406, y: 0.30447449684143066, z: 0.030637264251708984},
rotateSwordLeft()
]
},
modelURL: 'http://hifi-content.s3.amazonaws.com/alan/dev/equip-Fresnel-3.fbx',
modelScale: {
x: 1,
y: 1,
z: 1
}
}],
"noGear": true
}),
name: "ROC-Sword",
modelURL: "https://hifi-content.s3.amazonaws.com/jedon/Assets/broadsword_01.fbx",
shapeType: "static-mesh",
script: "https://hifi-content.s3.amazonaws.com/jedon/Game_Creater_Toolkit/SAO/SAO_Battle_Simulator.js?" + Date.now()
//script: "C:/Users/0425-DESKTOP-PC/Downloads/SAO_Battle_Simulator.js"
};
var newSword1 = Entities.addEntity(newSwordProp1);
//delete old sword
Entities.deleteEntity(sword2);
//cretae new sword
var newSwordProp2 = {
"type": "Model", //changed to Model when fixed
"lifetime": -1,
"position": swordPos2,
"collisionless": false,
"collidesWith": "static",
"rotation": swordRot,
"dynamic": true, //maybe change back to true
"damping": .9,
"angularDamping": .9,
//"visible": false, //changed for testing
userData: JSON.stringify({
grabbableKey: {
grabbable: false,
ignoreIK: false
},
equipHotspots: [{
position: {x: 0.11031082272529602, y: -0.13449540972709656, z: 0.0405043363571167},
radius: 0.25,
joints: { //x and y .15 increase
RightHand: [
{x: 0.26031082272529602, y: 0.31449540972709656, z: 0.0405043363571167},
rotateSwordRight()
],
LeftHand: [
{x: -0.25801754891872406, y: 0.30447449684143066, z: 0.030637264251708984},
rotateSwordLeft()
]
},
modelURL: 'http://hifi-content.s3.amazonaws.com/alan/dev/equip-Fresnel-3.fbx',
modelScale: {
x: 1,
y: 1,
z: 1
}
}],
"noGear": true
}),
name: "ROC-Sword",
modelURL: "https://hifi-content.s3.amazonaws.com/jedon/Assets/broadsword_01.fbx",
shapeType: "compound",
script: "https://hifi-content.s3.amazonaws.com/jedon/Game_Creater_Toolkit/SAO/SAO_Battle_Simulator.js?" + Date.now()
//script: "C:/Users/0425-DESKTOP-PC/Downloads/SAO_Battle_Simulator.js"
};
var newSword2 = Entities.addEntity(newSwordProp2);
//delete everything that came with the old swords (hearts, shields, etc)
Entities.callEntityMethod(sword1, "resetArena");
Entities.callEntityMethod(sword2, "resetArena");
//place new sword id's in sign
var newSignProp = {
grabbableKey: {
grabbable: false,
ignoreIK: false,
wantsTrigger: true
},
"sword1ID": newSword1,
"sword2ID": newSword2,
"swordPosition1": swordPos1,
"swordPosition2": swordPos2,
"swordRotation": swordRot
};
//send to sign
Entities.editEntity(this.entityID, { userData: JSON.stringify(newSignProp) });
};
function rotateSwordLeft()
{
var origRot = {x: -0.32700979709625244, y: 0.623619794845581, z: 0.28943854570388794, w: 0.6483823657035828};
var degreeRot = Quat.multiply(origRot, Quat.angleAxis(90, {x: 0, y: 1, z: 0}));
return degreeRot;
}
function rotateSwordRight()
{
var origRot = {x: 0.2807741165161133, y: 0.6332069635391235, z: 0.2997693121433258, w: -0.6557632088661194};
var degreeRot = Quat.multiply(origRot, Quat.angleAxis(90, {x: 0, y: 1, z: 0}));
return degreeRot;
}
})