Skip to content

Commit

Permalink
bunch of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Frotty committed Jul 7, 2024
1 parent 82ad6f7 commit fcffb57
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 126 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
[*] Fixed bug with walking across regions as escaper
[*] Fixed splitting of random killers
[*] Fixed JukeBox issues
[*] Improved Powernode bounce behavior
[*] Added new Minigame: Warlock

[0.92u]
[*] Added new minigame Agario
Expand Down
4 changes: 2 additions & 2 deletions wurst.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dependencies:
- https://github.com/wurstscript/wurstStdlib2
- https://github.com/frotty/frentity
buildMapData:
name: "|cff217199Escape Builder |r[R] 0.93a"
fileName: "Escape Builder[R] 0.93a"
name: "|cff217199Escape Builder |r[R] 0.93b"
fileName: "Escape Builder[R] 0.93b"
author: Frotty
players:
- id: 0
Expand Down
134 changes: 60 additions & 74 deletions wurst/builder/JukeBox.wurst
Original file line number Diff line number Diff line change
@@ -1,123 +1,109 @@
package JukeBox
import LinkedList
import TimerUtils
import Players
import SyncSimple
import ClosureTimers

class Music
int spellid
string path
real duration
string name

construct(int id, string path)
construct(int id, string path, real duration)
this.spellid = id
this.path = path
this.name = path.substring(path.lastIndexOf("\\") + 1, path.lastIndexOf("."))
let p = ALL_PLAYERS.getFirst()
if localPlayer == p
GetSoundFileDuration(path).sync(p) syncedDur ->
duration = syncedDur / 1000
this.duration = duration

function play() returns Music
PlayThematicMusic(path)
return this


class JukeRequest
player juker
int id
Music music

construct(player p, int id)
construct(player p, Music music)
this.juker = p
this.id = id
this.music = music


public JukeBox jukeBox
LinkedList<Music> musics
constant musics = new LinkedList<Music>()

public class JukeBox
let requests = new LinkedList<JukeRequest>()
let randomQueue = new LinkedList<int>()
let jukeTimer = getTimer()
let randomQueue = new LinkedList<Music>()

var lastWasRequest = false

Music currentMusic

construct()
jukeTimer.setData(this castTo int)
for n = 0 to 3
for i = 0 to musics.size()
if (i * GetRandomInt(1,7)) mod 2 == 0
randomQueue.addtoStart(i)
else
randomQueue.add(i)
CallbackSingle cb = null

function playNextMusic()
StopMusic(false)
// If request in queue, play it
if requests.size() > 0
lastWasRequest = true
let req = requests.pop()
currentMusic = musics.get(req.id)
currentMusic = req.music.play()
printTimed("Jukebox: Playing |cff84DE52" + currentMusic.name + "|r as requested by " + req.juker.getNameColored(), 10)
destroy req
else if randomQueue.size() > 0
let id = randomQueue.pop()
currentMusic = musics.get(id)
if currentMusic == null
playNextMusic()
return
printTimed("Jukebox: Playing |cff84DE52" + currentMusic.name + "|r", 10)
randomQueue.addtoStart(id)
lastWasRequest = false
if currentMusic != null
PlayMusic(currentMusic.path)
jukeTimer.start(currentMusic.duration + 0.01, () -> onMusicCallback())
else
StopMusic(false)
jukeTimer.start(60, () -> onMusicCallback())
// Play next random music
lastWasRequest = false
if randomQueue.size() == 0
randomQueue.addAll(musics)
randomQueue.shuffle()
currentMusic = randomQueue.pop().play()
printTimed("Jukebox: Playing |cff84DE52" + currentMusic.name + "|r", 10)

if cb != null
destroy cb
cb = doAfter(currentMusic.duration + 1) ->
cb = null
playNextMusic()

function checkSpell(int id)
int idx = 0
for music from musics.staticItr()
for music in musics
if music.spellid == id
let p = GetTriggerUnit().getOwner()
for req from requests.staticItr()
for req in requests
if req.juker == p
printTimedToPlayer("You already have a track in the jukebox!", 10, p)
printTimedToPlayer("You already have a track queued in the jukebox!", 10, p)
return

printTimed("The Track |cff84DE52" + music.name + "|r has been queued by " + p.getNameColored(), 10)
requests.add(new JukeRequest(p, idx))
printTimed("The Track |cff84DE52" + music.name + "|r has been requested by " + p.getNameColored(), 10)
requests.add(new JukeRequest(p, music))
if requests.size() == 1 and not lastWasRequest
jukeTimer.start(0.5, () -> onMusicCallback())
playNextMusic()
return
idx++

function onMusicCallback()
(GetExpiredTimer().getData() castTo JukeBox).playNextMusic()

init
musics = new LinkedList<Music>()
musics.add(new Music('A03T', "Sound\\Music\\mp3Music\\Doom.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Human1.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Human2.mp3"))
musics.add(new Music('A03L', "Sound\\Music\\mp3Music\\HumanX1.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc1.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc2.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc3.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\OrcX1.mp3"))
musics.add(new Music('A02R', "Sound\\Music\\mp3Music\\PursuitTheme.mp3"))
musics.add(new Music('A03P', "Sound\\Music\\mp3Music\\SadMystery.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Tension.mp3"))
musics.add(new Music('A03U', "Sound\\Music\\mp3Music\\TragicConfrontation.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Undead1.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Undead2.mp3"))
musics.add(new Music('A03O', "Sound\\Music\\mp3Music\\PH1.mp3"))
musics.add(new Music('A03M', "Sound\\Music\\mp3Music\\ArthasTheme.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\BloodElfTheme.mp3"))
musics.add(new Music('A03S', "Sound\\Music\\mp3Music\\War2IntroMusic.mp3"))
musics.add(new Music('A03Q', "Sound\\Music\\mp3Music\\Credits.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Comradeship.mp3"))
musics.add(new Music('A03N', "Sound\\Music\\mp3Music\\DarkAgents.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\IllidansTheme.mp3"))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\LichKingTheme.mp3"))
musics.add(new Music('A03R', "Sound\\Music\\mp3Music\\NagaTheme.mp3"))
jukeBox = new JukeBox()
doAfter(0.1) ->
musics.add(new Music('A03T', "Sound\\Music\\mp3Music\\Doom.mp3", 66.125))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Human1.mp3", 273.032))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Human2.mp3", 236.983))
musics.add(new Music('A03L', "Sound\\Music\\mp3Music\\HumanX1.mp3", 284.646))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc1.mp3", 311.954))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc2.mp3", 313.496))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc3.mp3", 282.706))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\OrcX1.mp3", 324.953))
musics.add(new Music('A02R', "Sound\\Music\\mp3Music\\PursuitTheme.mp3", 86.537))
musics.add(new Music('A03P', "Sound\\Music\\mp3Music\\SadMystery.mp3", 84.515))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Tension.mp3", 19.540))
musics.add(new Music('A03U', "Sound\\Music\\mp3Music\\TragicConfrontation.mp3", 72.264))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Undead1.mp3", 303.507))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Undead2.mp3", 309.242))
musics.add(new Music('A03O', "Sound\\Music\\mp3Music\\PH1.mp3", 281.582))
musics.add(new Music('A03M', "Sound\\Music\\mp3Music\\ArthasTheme.mp3", 122.295))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\BloodElfTheme.mp3", 144.552))
musics.add(new Music('A03S', "Sound\\Music\\mp3Music\\War2IntroMusic.mp3", 81.136))
musics.add(new Music('A03Q', "Sound\\Music\\mp3Music\\Credits.mp3", 83.017))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Comradeship.mp3", 124.927))
musics.add(new Music('A03N', "Sound\\Music\\mp3Music\\DarkAgents.mp3", 64.950))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\IllidansTheme.mp3", 108.006))
musics.add(new Music('0000', "Sound\\Music\\mp3Music\\LichKingTheme.mp3", 79.193))
musics.add(new Music('A03R', "Sound\\Music\\mp3Music\\NagaTheme.mp3", 87.1877))
jukeBox = new JukeBox()
9 changes: 4 additions & 5 deletions wurst/escaper/Escaper.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,12 @@ public abstract class Escaper extends UnitEntity

override function onGroundHit()
if pos.getEBRTile().modifiers.get(TileModifier.BLUGOO castTo int) and vel.z.abs() > 2
let rdata = this.getCurrentRegion()
let ttype = GetTerrainType(pos.x, pos.y)
// Handle Goo it
let angl = actor.getFacingAngle()
if ttype == CONTROLLABLEICE
vel.x = 0
vel.y = 0
slideVelocity = vec2(angl.cos() * rdata.slidespeed * SLIDE_ADD, angl.sin() * rdata.slidespeed * SLIDE_ADD)
let length = vel.length()
vel = angl.toVec(length).withZ(vel.z)
vel.z = -vel.z * 1.25
else
pos.z = 0
Expand Down Expand Up @@ -235,7 +233,8 @@ public abstract class Escaper extends UnitEntity
setLava(false)
else
if pos.getEBRTile().hasModifier(TileModifier.ORANGEGOO)
vel += walkVel
if vel.lengthSquared() < 1
vel = walkVel.toVec3()
vel *= 1.0075
vel *= 0.96
sliding = false
Expand Down
5 changes: 4 additions & 1 deletion wurst/init/GameInit.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function partThree()

function syncInitial()
startChoose()
jukeBox.playNextMusic()
ClearMapMusic()
StopMusic(false)
doAfter(1.) ->
jukeBox.playNextMusic()
startPick()

@compiletime function callGen()
Expand Down
2 changes: 1 addition & 1 deletion wurst/minigames/MGAgar.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ public class MGAgar extends Minigame
return "|cff567eecAgario\n\n|r >> |cff8cbfddBe the last one standing!"

init
// minigames.add(new MGAgar())
minigames.add(new MGAgar())
2 changes: 1 addition & 1 deletion wurst/minigames/MGRandKill.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ public class MGRandKill extends Minigame
return "|cffccaaddRandom Rumble"

init
// minigames.add(new MGRandKill())
minigames.add(new MGRandKill())
2 changes: 1 addition & 1 deletion wurst/minigames/MGSlide.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ public class MGSlide extends Minigame
return "|cff567eecSlide Fun\n\n|r >> |cff8cbfddGet to the other side in 12 seconds!"

init
// minigames.add(new MGSlide())
minigames.add(new MGSlide())
2 changes: 1 addition & 1 deletion wurst/minigames/MGSpacey.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class MGSpacey extends Minigame
constant minigame = new MGSpacey()

init
// minigames.add(minigame)
minigames.add(minigame)

constant SHIP_ID = compiletime(UNIT_ID_GEN.next())

Expand Down
10 changes: 6 additions & 4 deletions wurst/minigames/MGWarlock.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MGWarlock extends Minigame
warlocks.add(new Warlock(ARENA_POS + vec2(GetRandomReal(-16, 16), GetRandomReal(-16, 16)), pd.escaper))

cb = doPeriodically(1.) (CallbackPeriodic cb) ->
if warlocks.size() == 1
if warlocks.filter(warlock -> warlock.actor.isAlive()).size() == 1
for ep in escaperPlayers
printTimedToPlayer(warlocks.peek().mounter.owner.getNameColored(true) + " has won!", 10, ep.p)
reset()
Expand Down Expand Up @@ -106,14 +106,14 @@ public class Fireball extends Projectile
construct(Warlock caster, angle direction)
super(caster.pos.toVec2().withZ(42.), 46., STAFF_PLAYER, direction, Abilities.fireBallMissile)
this.caster = caster
setSpeed(2)
setSpeed(10)
setRanged(800)
reg = this.setCurrentRegion()

override function update()
super.update()
MGWarlock.warlocks.forEach() (Warlock target) ->
if target != caster and target.getPos().distanceTo2dSq(pos.toVec2()) < (radius2 + target.radius2)
if target.actor.isAlive() and target != caster and target.getPos().distanceTo2dSq(pos.toVec2()) < (radius2 + target.radius2)
new DummyDamage()..target(target.actor)..amount(10).apply(true)
(target).addVel(((target.getPos().toVec2() - getPos().toVec2()).norm() * 40).toVec3())
terminate()
Expand All @@ -134,11 +134,13 @@ public class Fireball extends Projectile

new ChannelAbilityPreset(FIREBALL_ID, 1, true)
..presetIcon(Icons.bTNFireBolt)
..presetCooldown(lvl -> 5.)
..presetCooldown(lvl -> 4.)
..presetManaCost(lvl -> 0)
..setName("Fireball")
..presetTooltipNormal(lvl -> "Fireball")
..presetButtonPosNormal(0, 0)
..presetHotkey("Q")
..presetTargetTypes(Targettype.POINT)
..presetCastRange(lvl -> 1500.)
..presetCastingTime(lvl -> 0.)
..presetArtDuration(lvl -> 0.)
3 changes: 2 additions & 1 deletion wurst/objects/circles/Trap.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class Trap extends StaticBaseObject
for i = 0 to 4
if goos[i] != null
destroy goos[i]
goos[i] = null

override function update()
if timerreal <= 0.0
Expand Down Expand Up @@ -330,7 +331,7 @@ public class Trap extends StaticBaseObject
actor.addAbility(KNOCKBACK_PULL_ID)
case SPECIAL_ID
let tile = tpos.getEBRTile()
if not tile.hasModifier(TileModifier.ORANGEGOO) and goocounter < 5
if not tile.hasModifier(TileModifier.ORANGEGOO) and goocounter < 4
let goo = createImage("textures\\orangegoo.blp", tpos, 128, 128)..show()
goos[goocounter] = new Goo(goo, tpos)
goocounter++
Expand Down
44 changes: 44 additions & 0 deletions wurst/objects/second/BounceTest.wurst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package BounceTest

public function calculateNormal(vec2 pointA, vec2 pointB, vec2 pointC) returns vec2
let vectorAB = pointB - pointA
let vectorAC = pointC - pointA

// Calculate the cross product of AB and AC (only Z component since we're in 2D)
let crossProductZ = vectorAB.x * vectorAC.y - vectorAB.y * vectorAC.x

// Determine the normal based on the cross product sign
vec2 normal
if crossProductZ > 0
normal = vec2(-vectorAB.y, vectorAB.x) // Left normal
else
normal = vec2(vectorAB.y, -vectorAB.x) // Right normal

// Normalize the normal vector
return normal.norm()

public function reflectVelocity(vec2 velocity, vec2 normal, real reboundFactor) returns vec2
// Calculate the dot product of velocity and normalized normal
let dotProduct = velocity.dot(normal)

// Calculate the reflection vector
var reflection = velocity - (2 * dotProduct * normal)

// // Calculate the cosine of the angle between vel3 and nor3
// let cosAngle = dotProduct / (velocity.length() * normal.length())

// print(cosAngle.toString())
// // Check if the angle is very small (cosAngle close to 1 means angle close to 0)
// if (cosAngle > 0.5) // Adjust this threshold based on your needs
// // For nearly parallel, reduce the reflection magnitude
// reflection *= 0.5 // Example: reduce the reflection's magnitude

// Apply the rebound factor
let reflectedVelocity = reflection * reboundFactor

return reflectedVelocity

@Test function test()
calculateNormal(vec2(0, 0), vec2(1, 0), vec2(0, 0.5)).assertEquals(vec2(0, 1.0))
print(calculateNormal(vec2(0, 0), vec2(1, 0), vec2(0, 0.5)).toString())
print(reflectVelocity(vec2(0.5, -0.5), calculateNormal(vec2(0, 0), vec2(1, 0), vec2(0, 0.5)), 1.).toString())
Loading

0 comments on commit fcffb57

Please sign in to comment.