--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua Thu Mar 08 15:01:18 2018 -0500
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua Thu Mar 08 21:05:10 2018 +0100
@@ -569,7 +569,7 @@
sprTargetBee, sprAmGirder, sprAmRubber, sprIceTexture, sprHHTelepMask,
sprAMAmmos, sprAMAmmosBW, sprAMSlot, sprAMCorners, sprTurnsLeft, sprBotlevels,
sprSpeechCorner, sprSpeechEdge, sprSpeechTail, sprThoughtCorner, sprThoughtEdge, sprThoughtTail,
- sprShoutCorner, sprShoutEdge, sprShoutTail, sprCustom1, sprCustom2, }
+ sprShoutCorner, sprShoutEdge, sprShoutTail, }
-- Set in onGameInit
local reducedSpriteIDArrayFrames
@@ -578,7 +578,7 @@
"sprTargetBee", "sprAmGirder", "sprAmRubber", "sprIceTexture", "sprHHTelepMask",
"sprAMAmmos", "sprAMAmmosBW", "sprAMSlot", "sprAMCorners", "sprTurnsLeft", "sprBotlevels",
"sprSpeechCorner", "sprSpeechEdge", "sprSpeechTail", "sprThoughtCorner", "sprThoughtEdge", "sprThoughtTail",
- "sprShoutCorner", "sprShoutEdge", "sprShoutTail", "sprCustom1", "sprCustom2", }
+ "sprShoutCorner", "sprShoutEdge", "sprShoutTail", }
----------------------------
-- placement shite
@@ -593,7 +593,8 @@
local helpDisabled = false --determines whether help popups pop up
local CG = nil -- this is the visual gear displayed at CursorX, CursorY
local crateSprite = nil-- this is a visual gear aid for crate placement
-local tSpr = {}
+local crateSpriteBorer = nil
+local waypointPreviewSprite = nil
local cGear = nil -- detects placement of girders and objects (using airattack)
local curWep = amNothing
@@ -654,6 +655,8 @@
local closestGear = nil
local closestSpriteID = nil
+local wpRadius = 450
+
------------------------
-- SOME GENERAL METHODS
------------------------
@@ -902,8 +905,8 @@
placedSprite[placedCount] = vgtCircle
placedSpec[placedCount] = AddVisualGear(x,y,vgtCircle,0,true)
placedTint[placedCount] = 0xFF0000FF
- placedFrame[placedCount] = 1 --rad is 450
- SetVisualGearValues(placedSpec[placedCount], x, y, 164, 224, 1, 10, 0, 450, 5, placedTint[placedCount])
+ placedFrame[placedCount] = 1
+ SetVisualGearValues(placedSpec[placedCount], x, y, 164, 224, 1, 10, 0, wpRadius, 5, placedTint[placedCount])
placedCount = placedCount +1
end
@@ -963,7 +966,11 @@
end
-function CallPlaceSprite(pID)
+function CallPlaceSprite(pID, silent)
+
+ if silent == nil then
+ silent = false
+ end
if landType == lfIce then
placedLandFlags[pID] = "lfIce"
@@ -986,12 +993,22 @@
actualDisplayedImage = ammoFrameAirAttack
end
- return PlaceSprite(placedX[pID], placedY[pID], placedSprite[pID], actualDisplayedImage,
+ local success = PlaceSprite(placedX[pID], placedY[pID], placedSprite[pID], actualDisplayedImage,
placedTint[pID],
nil, -- overrite existing land
nil, nil, -- this stuff specifies flipping
landType)
+ if not silent then
+ if success then
+ PlaySound(sndPlaced)
+ else
+ PlaySound(sndDenied)
+ end
+ end
+
+ return success
+
end
function SelectClosestSprite()
@@ -1030,6 +1047,8 @@
nil, -- flip sprite vertically
placedLandFlags[closestSpriteID])
+ PlaySound(sndBump)
+
placedX[closestSpriteID] = nil
placedY[closestSpriteID] = nil
placedSpec[closestSpriteID] = nil
@@ -1040,6 +1059,8 @@
placedLandFlags[closestSpriteID] = nil
closestSpriteID = nil
SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 )
+ else
+ PlaySound(sndDenied)
end
end
@@ -1051,16 +1072,15 @@
for i = 0, (placedCount-1) do
if (placedType[i] == loc("Waypoint Editing Mode")) then
- q = placedX[i] - placedX[placedCount]
- w = placedY[i] - placedY[placedCount]
- d = ( (q*q) + (w*w) )
- if d < closestDist then
- closestDist = d
- closestSpriteID = i
-
- SetVisualGearValues(sSprite, placedX[i], placedY[i], 0, 0, nil, placedFrame[i], 10000, placedSprite[i], 10000, newTint )
-
- end
+ local q = placedX[i] - placedX[placedCount]
+ local w = placedY[i] - placedY[placedCount]
+ local d = ( (q*q) + (w*w) )
+ if d < closestDist then
+ closestDist = d
+ closestSpriteID = i
+
+ SetVisualGearValues(sSprite, placedX[i], placedY[i], 0, 0, nil, placedFrame[i], 10000, placedSprite[i], 10000, newTint )
+ end
end
end
@@ -1076,6 +1096,9 @@
placedLandFlags[closestSpriteID] = nil
closestSpriteID = nil
SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 )
+ PlaySound(sndBump)
+ else
+ PlaySound(sndDenied)
end
end
@@ -1139,8 +1162,10 @@
elseif CGR == 2 then placedHWMapFlag[placedCount] = 126
elseif CGR == 3 then placedHWMapFlag[placedCount] = 127
end
+ PlaySound(sndPlaced)
else
placedType[placedCount] = "bogus"
+ PlaySound(sndDenied)
end
else
placedType[placedCount] = "bogus"
@@ -1184,18 +1209,25 @@
if pMode[pIndex] == loc("Selection Mode") then
sGear = GetClosestGear()
+ if sGear ~= nil then
+ PlaySound(sndPortalSwitch)
+ end
elseif pMode[pIndex] == loc("Placement Mode") then
if sGear ~= nil then
SetGearPosition(sGear, x, y)
+ PlaySound(sndWarp)
end
elseif pMode[pIndex] == loc("Deletion Mode") then
sGear = GetClosestGear()
if (sGear == nil) then
AddCaption(loc("Please click on a gear."), colorErrorMessage, capgrpVolume)
+ PlaySound(sndDenied)
elseif (GetGearType(sGear) == gtHedgehog) then
AddCaption(loc("Hedgehogs can not be deleted."), colorErrorMessage, capgrpVolume)
+ PlaySound(sndDenied)
else
DeleteGear(sGear)
+ PlaySound(sndBump)
end
sGear = nil
end
@@ -1209,8 +1241,10 @@
else -- set for the whole team
SetTeamIdentity(sGear)
end
+ PlaySound(sndHello, sGear)
else
AddCaption(loc("Please click on a hedgehog."), colorErrorMessage, capgrpVolume)
+ PlaySound(sndDenied)
end
@@ -1220,13 +1254,21 @@
sGear = GetClosestGear()
local gt = GetGearType(sGear)
if gt == gtHedgehog or gt == gtExplosives or (gt == gtCase and GetGearPos(sGear) == 0x2) then
+ local oldHealth, hDiff = GetHealth(sGear)
if pMode[pIndex][2] == "set" then
SetHealth(sGear, pMode[pIndex][1])
+ hDiff = pMode[pIndex][1] - oldHealth
elseif pMode[pIndex][2] == "mod" then
local min
if gt == gtCase then min = 0 else min = 1 end
local newHealth = math.max(min, GetHealth(sGear) + tonumber(pMode[pIndex][1]))
SetHealth(sGear, newHealth)
+ hDiff = newHealth - oldHealth
+ end
+ PlaySound(sndPortalSwitch)
+ if gt == gtHedgehog and hDiff < 0 then
+ local snd = { sndOw1, sndOw2, sndOw3 }
+ PlaySound(snd[math.random(1, #snd)], sGear)
end
elseif gt == gtMine and GetHealth(sGear) == 0 then
local newHealth
@@ -1240,9 +1282,11 @@
end
if newHealth ~= nil then
SetGearValues(sGear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 36 - newHealth)
+ PlaySound(sndPortalSwitch)
end
else
AddCaption(loc("Please click on a hedgehog, barrel, health crate or dud mine."), colorErrorMessage, capgrpVolume)
+ PlaySound(sndDenied)
end
elseif cat[cIndex] == loc("Sprite Modification Mode") then
@@ -1252,16 +1296,21 @@
if closestSpriteID ~= nil then
if pMode[pIndex] == loc("LandFlag Modification Mode") then
EraseSprite(placedX[closestSpriteID], placedY[closestSpriteID], placedSprite[closestSpriteID], placedFrame[closestSpriteID], nil, nil, nil, nil, placedLandFlags[closestSpriteID])
- placementSucceeded = CallPlaceSprite(closestSpriteID)
+ placementSucceeded = CallPlaceSprite(closestSpriteID, true)
if placementSucceeded then
closestSpriteID = nil
SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 )
+ PlaySound(sndPortalSwitch)
+ else
+ PlaySound(sndDenied)
end
elseif pMode[pIndex] == loc("Sprite Erasure Mode") then
EraseClosestSprite()
end
+ else
+ PlaySound(sndDenied)
end
@@ -1275,14 +1324,18 @@
if pMode[pIndex] == loc("Victory Condition: Collect") then
if GetGearType(sGear) == gtCase then
setGearValue(sGear, "tag","collection")
+ PlaySound(sndPortalSwitch)
else
AddCaption(loc("Please click on a crate."), colorErrorMessage, capgrpVolume)
+ PlaySound(sndDenied)
end
else
if pMode[pIndex] == loc("Victory Condition: Destroy") then
setGearValue(sGear, "tag","victory")
+ PlaySound(sndPortalSwitch)
elseif pMode[pIndex] == loc("Losing Condition: Destroy") then
setGearValue(sGear, "tag","failure")
+ PlaySound(sndPortalSwitch)
end
end
@@ -1291,6 +1344,7 @@
setGearValue(sGear, "tag", nil)
DeleteVisualGear(getGearValue(sGear,"tCirc"))
setGearValue(sGear, "tCirc", nil)
+ PlaySound(sndBump)
end
@@ -1304,9 +1358,6 @@
placedFrame[placedCount] = sFrame
placedSprite[placedCount] = reducedSpriteIDArray[pIndex]
placementSucceeded = CallPlaceSprite(placedCount)
- if placementSucceeded then
- PlaySound(sndPlaced)
- end
else
placedType[placedCount] = "bogus"
SelectClosestSprite()
@@ -2850,7 +2901,6 @@
genTimer = genTimer + 1
-
tSprCol = 0x00000000
tempFrame = 0
xDisplacement = 42
@@ -2858,19 +2908,18 @@
if (curWep == amCMGearPlacementTool) then
+ SetSoundMask(sndIncoming, true)
+
--wowaweewa, holyeeeee shite this is badly hacked (please rewrite when less lazy/morefeatures)
dCol = 0xFFFFFFFF
dFrame = 0
dAngle = 0
if (cat[cIndex] == loc("Mine Placement Mode")) then
- dSprite = sprBotlevels--sprMineOff
- dFrame = 1
+ dSprite = sprCustom2
elseif (cat[cIndex] == loc("Dud Mine Placement Mode")) then
- dSprite = sprBotlevels--sprMineDead
- dFrame = 3
+ dSprite = sprCustom4
elseif (cat[cIndex] == loc("Sticky Mine Placement Mode")) then
- dSprite = sprBotlevels--sprSMineOff
- dFrame = 2
+ dSprite = sprCustom3
elseif (cat[cIndex] == loc("Air Mine Placement Mode")) then
dSprite = sprAirMine
elseif (cat[cIndex] == loc("Barrel Placement Mode")) then
@@ -2907,9 +2956,7 @@
if crateSprite == nil then
crateSprite = AddVisualGear(CursorX, CursorY-35, vgtStraightShot,0,true,3)
- for i = 1, 4 do
- tSpr[i] = AddVisualGear(CursorX, CursorY-35, vgtStraightShot,0,true,3)
- end
+ crateSpriteBorder = AddVisualGear(CursorX, CursorY-35, vgtStraightShot,0,true,3)
end
@@ -2931,18 +2978,29 @@
end
end
+ -- Waypoint outline
+ if (cat[cIndex] == loc("Waypoint Editing Mode")) and (pMode[pIndex] == loc("Place Waypoint")) then
+ if not waypointPreviewSprite then
+ waypointPreviewSprite = AddVisualGear(CursorX, CursorY, vgtCircle, 1, true)
+ SetVisualGearValues(waypointPreviewSprite, CursorX, CursorY, 244, 224, 0, 0, 0, wpRadius/5, 5, 0xFF0000FF)
+ end
+ elseif waypointPreviewSprite then
+ DeleteVisualGear(waypointPreviewSprite)
+ waypointPreviewSprite = nil
+ end
+ if waypointPreviewSprite then
+ SetVisualGearValues(waypointPreviewSprite, CursorX, CursorY)
+ end
+
else
+ SetSoundMask(sndIncoming, false)
if CG ~= nil then
SetVisualGearValues(CG, 0, 0, 0, 0, 0, 0, 1000, sprArrow, 1000, 0xFFFFFF00)
end
end
SetVisualGearValues(crateSprite, CursorX+xDisplacement, CursorY+yDisplacement, 0, 0, dAngle, tempFrame, 1000, sprAMAmmos, 1000, tSprCol)
- SetVisualGearValues(tSpr[1], CursorX+xDisplacement-2, CursorY+yDisplacement-2, 0, 0, dAngle, 1, 1000, sprTarget, 1000, tSprCol)
- SetVisualGearValues(tSpr[2], CursorX+xDisplacement-2, CursorY+yDisplacement+2, 0, 0, dAngle, 1, 1000, sprTarget, 1000, tSprCol)
- SetVisualGearValues(tSpr[3], CursorX+xDisplacement+2, CursorY+yDisplacement-2, 0, 0, dAngle, 1, 1000, sprTarget, 1000, tSprCol)
- SetVisualGearValues(tSpr[4], CursorX+xDisplacement+2, CursorY+yDisplacement+2, 0, 0, dAngle, 1, 1000, sprTarget, 1000, tSprCol)
-
+ SetVisualGearValues(crateSpriteBorder, CursorX+xDisplacement, CursorY+yDisplacement, 0, 0, 0, 0, 1000, sprCustom1, 1000, tSprCol)
if genTimer >= 100 then
@@ -2971,6 +3029,12 @@
RedefineSubset()
end
+ if curWep == amGirder or curWep == amRubber then
+ SetSoundMask(sndDenied, true)
+ else
+ SetSoundMask(sndDenied, false)
+ end
+
-- update display selection criteria
if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMGearPlacementTool) then
AddCaption(cat[cIndex], colorPlaceMode1, capgrpMessage)