Skip to content

Commit

Permalink
New Feature & de_vertigo Fix
Browse files Browse the repository at this point in the history
Add incgrenade&molotov feature on radar

Fix offSet on de_vertigo and replace the radar image with the new version de_vertigo
  • Loading branch information
wuXinnnn committed Aug 31, 2019
1 parent bfa1428 commit fd90076
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 9 deletions.
2 changes: 1 addition & 1 deletion html/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<img id="radar" src="">

<div id="smokes"></div>

<div id="infernos"></div>
<div id="entities">
<div id="siteA"></div>
<div id="siteB"></div>
Expand Down
46 changes: 40 additions & 6 deletions http.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const remotenades = require("./remotenades.js")
const host = "localhost"

let oldPhase = false

let infernosOnMap = [] //initial molotov status
let server = http.createServer(function(req, res) {
if (req.method != "POST") {
res.writeHead(405)
Expand Down Expand Up @@ -111,11 +111,11 @@ let server = http.createServer(function(req, res) {
}
})
}

if (game.grenades) {
let smokes = []
let nades = []

let infernos = []
for (let nadeID in game.grenades) {
let nade = game.grenades[nadeID]

Expand All @@ -131,13 +131,45 @@ let server = http.createServer(function(req, res) {
}
})
}
if (nade.type == "inferno") {
if (!!nade.flames) {
let flamesPos = []
let flamesNum = Object.values(nade.flames).length
for (var i = 0; i < flamesNum; i++) {
flamesPos.push({
x: parseFloat(Object.values(nade.flames)[i].split(", ")[0]),
y: parseFloat(Object.values(nade.flames)[i].split(", ")[1]),
z: parseFloat(Object.values(nade.flames)[i].split(", ")[2]),
})
}
infernos.push({
id: nadeID,
flamesNum: flamesNum,
flamesPosition: flamesPos
})
if (infernosOnMap.indexOf(nadeID) == -1 ) {infernosOnMap.push(nadeID)}
}
else{

}
}
}
for (let infernoOnMap of infernosOnMap) {
if (!game.grenades[infernoOnMap]) {
process.send({
type: "infernoRemove",
data: infernoOnMap
})
}// check if molotov exist in game
}

process.send({
type: "smokes",
data: smokes
})

process.send({
type: "infernos",
data: infernos
})
if (config.nadeCollection) {
remotenades.event(game.grenades)
}
Expand All @@ -148,7 +180,9 @@ let server = http.createServer(function(req, res) {
type: "round",
data: game.round.phase
})

if (oldPhase == "over" && game.round.phase == "freezetime") {
infernosOnMap = [] //clear molotov status every round
}
if (oldPhase != game.round.phase && config.nadeCollection) {
if (oldPhase == "over" && game.round.phase == "freezetime") {
remotenades.send()
Expand Down
2 changes: 1 addition & 1 deletion maps/de_vertigo/meta.json5
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// The radar offset in percentages to apply when player is in the split
"offset": {
"x": 0,
"y": -39
"y": -43
}
}
],
Expand Down
Binary file modified maps/de_vertigo/radar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 38 additions & 1 deletion renderers/smokes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Shows smokes on map an calculates duration.

let global = require("./_global")

// The live position of all smokes
global.renderer.on("smokes", (event, smokes) => {
// Called to show the fade in animation with a delay
Expand Down Expand Up @@ -64,7 +63,45 @@ global.renderer.on("smokes", (event, smokes) => {
}
})

//molotov on radar
global.renderer.on("infernos", (event, infernos) => {
// Go through each smoke
for (let inferno of infernos) {
// Get the molotov element
let infernoElement = document.getElementById("inferno" + inferno.id)
let flameElementsStr = ""
let flameElement = []

// If the element does not exist yet, add it
if (!infernoElement) {
// Create a new element
infernoElement = document.createElement("div")
infernoElement.id = "inferno" + inferno.id
infernoElement.className = "inferno"
infernoElement.setAttribute('style', 'opacity:1')
document.getElementById("infernos").appendChild(infernoElement)

}
infernoElement = document.getElementById("inferno" + inferno.id)
for (var i = 0; i < inferno.flamesNum; i++) {
flameElement[i] = document.createElement("div")
flameElement[i].style.height = flameElement[i].style.width = 100 / global.mapData.resolution / 1024 * 100 + "%"
let percOffset = parseFloat(flameElement[i].style.height) / 2
flameElement[i].style.left = global.positionToPerc(inferno.flamesPosition[i], "x") + "%"
flameElement[i].style.bottom = global.positionToPerc(inferno.flamesPosition[i], "y") - percOffset + "%"
flameElementsStr = flameElementsStr + flameElement[i].outerHTML
}
infernoElement.innerHTML = flameElementsStr

}

})

global.renderer.on("infernoRemove", (event,infernoRemove) => {
document.getElementById("inferno" + infernoRemove).setAttribute('style', 'opacity:0')
})
// Clear all smokes on round reset
global.renderer.on("roundend", (event) => {
document.getElementById("smokes").innerHTML = ""
document.getElementById("infernos").innerHTML = ""
})
30 changes: 30 additions & 0 deletions style/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@ body {
transition: opacity 1.8s;
}

#infernos{
position: absolute;
height: 100%;
width: 100%;
bottom: 0;
left: 0;
z-index: 2;
}

.inferno{
position: absolute;
height: 100%;
width: 100%;
bottom: 0;
left: 0;
z-index: 2;
transition: opacity .3s;
}

.inferno > div{
position: absolute;
border-radius: 100%;
opacity: .75;
background: #ff4848;
box-sizing: border-box;
border: #ce3f00 solid 1.5px;
transform: translate(-50%, -50%);
transition: opacity .3s;
}

#siteA, #siteB {
position: absolute;
background: #f00;
Expand Down

0 comments on commit fd90076

Please sign in to comment.