~ubuntu-branches/ubuntu/trusty/hedgewars/trusty-proposed

« back to all changes in this revision

Viewing changes to share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-11-20 18:31:17 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20111120183117-pjhz1n2pvnmxa246
Tags: 0.9.17-1
* [Paul Wise]
 * Mention the homing bee in the package description (Closes: #577092)
 * Also install the hwengine desktop file (LP: #811770)
 * Depend on ttf-dejavu-core since it is smaller
 * Depend on ttf-wqy-zenhei instead of embedding a copy of it
* [Dmitry E. Oboukhov]
 * New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
---------------------------------------------------
6
6
---------------------------------------------------
7
7
---------------------------------------------------
8
 
--- Space Invasion Code Follows (0.9)
 
8
--- Space Invasion Code Follows (1.0)
9
9
---------------------------------------------------
10
10
---------------------------------------------------
11
11
-- VERSION HISTORY
86
86
-- Boss Slayer (Destroy 2 blue circles for +25 points)
87
87
 
88
88
-- Shield Master (disolve 5 shells for +10 points)
 
89
-- Shield Miser (don't use your shield at all (3.5*roundkills)+2 points)
89
90
 
90
91
-- Depleted Kamikaze! (kamikaze into a blue/red circ when you are out of ammo) 5pts
91
92
-- Timed Kamikaze! (kamikaze into a blue/red circ when you only have 5s left) 10pts
122
122
-- experimental radar (it's INTERACTIVE and math-heavy :D) (visual gears are safe... right? D:)
123
123
-- bugfix and balance for multishot
124
124
 
 
125
------------------------
 
126
-- version 1.0
 
127
------------------------
 
128
 
 
129
-- if only version numbers actually worked like this, wouldn't that be awful :D
 
130
 
 
131
-- added surfer achievement
 
132
-- increased value of shield miser by 1 point per kill (OP?)
 
133
 
 
134
 
125
135
--------------------------
126
136
--notes for later
127
137
--------------------------
152
162
AddCaption(LOC_NOT("BOOM! +50 points!"),0xffba00ff,capgrpVolume)
153
163
AddCaption(LOC_NOT("BOOM! BOOM! BOOM! +100 points!"),0xffba00ff,capgrpVolume)
154
164
AddCaption(LOC_NOT("Accuracy Bonus! +15 points!"),0xffba00ff,capgrpVolume)
 
165
AddCaption(loc("Surfer! +15 points!"),0xffba00ff,capgrpVolume)
155
166
 
156
167
-----------------
157
168
capgrpMessage
207
218
local sdName = {}
208
219
local sdKills = {}
209
220
 
 
221
local roundN = 0
 
222
local lastRound
 
223
local RoundHasChanged = true
 
224
 
210
225
--------------------------
211
226
-- hog and team tracking variales
212
227
--------------------------
223
238
local teamComment = {}
224
239
local teamScore = {}
225
240
local teamCircsKilled = {}
 
241
local teamSurfer = {}
226
242
 
227
243
-- stats variables
228
244
--local teamRed = {}
240
256
local chainLength = 0
241
257
local shotsFired = 0
242
258
local shotsHit = 0
 
259
local SurfTime = 0
243
260
 
244
261
---------------------
245
262
-- tumbler goods
382
399
                teamIndex[i] = 0
383
400
                teamScore[i] = 0
384
401
                teamCircsKilled[i] = 0
 
402
                teamSurfer[i] = false
385
403
        end
386
404
        numTeams = 0
387
405
 
445
463
function AwardKills(t)
446
464
 
447
465
        roundKills = roundKills + 1
448
 
        
 
466
 
449
467
        for i = 0,(TeamsCount-1) do
450
468
                if teamClan[i] == GetHogClan(CurrentHedgehog) then
451
469
                        teamCircsKilled[i] = teamCircsKilled[i] + 1
533
551
 
534
552
end
535
553
 
 
554
function onNewRound()
 
555
        roundNumber = roundNumber + 1
 
556
 
 
557
        CommentOnScore()
 
558
 
 
559
        -- end game if its at round limit
 
560
        if roundNumber == roundLimit then
 
561
 
 
562
                for i = 0, (TeamsCount-1) do
 
563
                        if teamScore[i] > bestScore then
 
564
                                bestScore = teamScore[i]
 
565
                                bestClan = teamClan[i]
 
566
                        end
 
567
                end
 
568
 
 
569
                for i = 0, (numhhs-1) do
 
570
                        if GetHogClan(hhs[i]) ~= bestClan then
 
571
                                SetEffect(hhs[i], heResurrectable, false)
 
572
                                SetHealth(hhs[i],0)
 
573
                        end
 
574
                end
 
575
                gameOver = true
 
576
                TurnTimeLeft = 0        --1
 
577
                TimeLeft = 0
 
578
        end
 
579
end
 
580
 
536
581
-- gaudy racer
537
582
function CheckForNewRound()
538
583
 
 
584
        ----------
 
585
        -- new
 
586
        ----------
 
587
 
 
588
        --[[if gameBegun == true then
 
589
 
 
590
                if RoundHasChanged == true then
 
591
                        roundN = roundN + 1
 
592
                        RoundHasChanged = false
 
593
                        onNewRound()
 
594
                end
 
595
 
 
596
                if lastRound ~= TotalRounds then -- new round, but not really
 
597
 
 
598
                        if RoundHasChanged == false then
 
599
                                RoundHasChanged = true
 
600
                        end
 
601
 
 
602
                end
 
603
 
 
604
                --AddCaption("RoundN:" .. roundN .. "; " .. "TR: " .. TotalRounds)
 
605
                lastRound = TotalRounds
 
606
 
 
607
        end]]
 
608
 
 
609
        ----------
 
610
        -- old
 
611
        ----------
539
612
        if GetHogClan(CurrentHedgehog) == firstClan then
540
 
 
541
 
                roundNumber = roundNumber + 1
542
 
 
543
 
                CommentOnScore()
544
 
 
545
 
                -- end game if its at round limit
546
 
                if roundNumber == roundLimit then
547
 
 
548
 
                        for i = 0, (TeamsCount-1) do
549
 
                                if teamScore[i] > bestScore then
550
 
                                        bestScore = teamScore[i]
551
 
                                        bestClan = teamClan[i]
552
 
                                end
553
 
                        end
554
 
 
555
 
                        for i = 0, (numhhs-1) do
556
 
                                if GetHogClan(hhs[i]) ~= bestClan then
557
 
                                        SetEffect(hhs[i], heResurrectable, false)
558
 
                                        SetHealth(hhs[i],0)
559
 
                                end
560
 
                        end
561
 
                        gameOver = true
562
 
                        TurnTimeLeft = 0        --1
563
 
                        TimeLeft = 0
564
 
                end
565
 
 
 
613
                onNewRound()
566
614
        end
567
615
 
568
616
end
730
778
 
731
779
function onHJump()
732
780
 
733
 
        if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and 
 
781
        if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and
734
782
        (rAlpha == 255) and (radShotsLeft > 0) then
735
783
                rPingTimer = 0
736
784
                rAlpha = 0
833
881
 
834
882
        CreateMeSomeCircles()
835
883
        RebuildTeamInfo() -- control
 
884
        lastRound = TotalRounds
836
885
 
837
886
end
838
887
 
867
916
        shotsHit = 0
868
917
        chainLength = 0
869
918
        chainCounter = 0
 
919
        SurfTime = 12
870
920
 
871
921
        -------------------------
872
922
        -- gaudy racer
1024
1074
                                --nw WriteLnToConsole("Player is out of luck")
1025
1075
 
1026
1076
                                if shieldMiser == true then
1027
 
                                        
1028
 
                                        p = (roundKills*2.5) - ((roundKills*2.5)%1) + 2
1029
 
                                        --p = (roundKills*2.5) + 2
1030
 
                                        --if (p%2 ~= 0) then
1031
 
                                        --      p = p -0.5                                      
1032
 
                                        --end
 
1077
 
 
1078
                                        p = (roundKills*3.5) - ((roundKills*3.5)%1) + 2
1033
1079
 
1034
1080
                                        AddCaption(loc("Shield Miser!") .." +" .. p .." ".. loc("points") .. "!",0xffba00ff,capgrpAmmoinfo)
1035
1081
                                        AwardPoints(p)
1073
1119
                                --------------
1074
1120
                                --------------
1075
1121
 
 
1122
                                ------------------------
 
1123
                                -- surfer achievement
 
1124
                                ------------------------
 
1125
 
 
1126
                                if (WaterLine - GetY(CurrentHedgehog)) < 15 then
 
1127
                                        SurfTime = SurfTime -1
 
1128
                                end
 
1129
 
 
1130
                                if SurfTime ~= 12 then
 
1131
 
 
1132
                                        SurfTime = SurfTime - 1
 
1133
                                        if SurfTime <= 0 then
 
1134
                                                for i = 0,(TeamsCount-1) do
 
1135
                                                        if teamClan[i] == GetHogClan(CurrentHedgehog) and (teamSurfer[i] == false) then
 
1136
                                                                teamSurfer[i] = true
 
1137
                                                                SurfTime = 12
 
1138
                                                                AddCaption(loc("Surfer! +15 points!"),0xffba00ff,capgrpVolume)
 
1139
                                                                AwardPoints(15)
 
1140
                                                        end
 
1141
                                                end
 
1142
                                        end
 
1143
                                end
 
1144
 
 
1145
 
1076
1146
                                dx, dy = GetGearVelocity(CurrentHedgehog)
1077
1147
 
1078
1148
                                --WriteLnToConsole("I just got the velocity of currenthedgehog. It is dx: " .. dx .. "; dy: " .. dy)
1123
1193
        end
1124
1194
 
1125
1195
        --WriteLnToConsole("End of GameTick")
1126
 
        
 
1196
 
1127
1197
end
1128
1198
 
1129
1199
function onGearResurrect(gear)
1211
1281
 
1212
1282
function DoHorribleThings(cUID)
1213
1283
 
1214
 
        -- maybe        
 
1284
        -- maybe
1215
1285
        -- add a check to draw it inside the circ and not past it if
1216
1286
        -- it is closer than 150 or w/e
1217
1287
 
1218
 
        -- work out the distance to the target  
 
1288
        -- work out the distance to the target
1219
1289
        g1X, g1Y = GetGearPosition(CurrentHedgehog)
1220
1290
        g2X, g2Y = vCircX[cUID], vCircY[cUID]
1221
 
        q = g1X - g2X                           
1222
 
        w = g1Y - g2Y                           
 
1291
        q = g1X - g2X
 
1292
        w = g1Y - g2Y
1223
1293
        r = math.sqrt( (q*q) + (w*w) )  --alternate
1224
 
        
1225
 
 
1226
 
        opp = w 
 
1294
 
 
1295
 
 
1296
        opp = w
1227
1297
        if opp < 0 then
1228
1298
                opp = opp*-1
1229
1299
        end
1230
1300
 
1231
1301
        -- work out the angle (theta) to the target
1232
1302
        t = math.deg ( math.asin(opp / r) )
1233
 
                
1234
 
        -- based on the radius of the radar, calculate what x/y displacement should be  
 
1303
 
 
1304
        -- based on the radius of the radar, calculate what x/y displacement should be
1235
1305
        NR = 150 -- radius at which to draw circs
1236
1306
        NX = math.cos( math.rad(t) ) * NR
1237
 
        NY = math.sin( math.rad(t) ) * NR       
1238
 
                
 
1307
        NY = math.sin( math.rad(t) ) * NR
 
1308
 
1239
1309
        -- displace xy based on where this thing actually is
1240
1310
        if q > 0 then
1241
1311
                rCircX[cUID] = g1X - NX
1248
1318
        else
1249
1319
                rCircY[cUID] = g1Y + NY
1250
1320
        end
1251
 
        
 
1321
 
1252
1322
end
1253
1323
 
1254
1324
function PlayerIsFine()
1573
1643
 
1574
1644
        g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(rCirc[i])
1575
1645
        SetVisualGearValues(rCirc[i], 0, 0, g3, g4, g5, g6, g7, g8, g9, vCircCol[i]-0x000000ff)
1576
 
        
 
1646
 
1577
1647
 
1578
1648
        vCircActive[i] = true -- new
1579
1649
 
1816
1886
 
1817
1887
        end]]
1818
1888
 
1819
 
        
 
1889
 
1820
1890
        if rAlpha ~= 255 then
1821
 
                
 
1891
 
1822
1892
                rPingTimer = rPingTimer + 1
1823
1893
                if rPingTimer == 100 then
1824
 
                        rPingTimer = 0  
1825
 
                        
 
1894
                        rPingTimer = 0
 
1895
 
1826
1896
                        rAlpha = rAlpha + 5
1827
1897
                        if rAlpha >= 255 then
1828
1898
                                rAlpha = 255
1829
 
                        end     
 
1899
                        end
1830
1900
                end
1831
 
        
 
1901
 
1832
1902
        end
1833
1903
 
1834
1904
        for i = 0,(vCCount-1) do
1835
1905
 
1836
1906
                --if (vCircActive[i] == true) then
1837
 
                        SetVisualGearValues(rCirc[i], rCircX[i], rCircY[i], 100, 255, 1, 10, 0, 40, 3, vCircCol[i]-rAlpha)      
 
1907
                        SetVisualGearValues(rCirc[i], rCircX[i], rCircY[i], 100, 255, 1, 10, 0, 40, 3, vCircCol[i]-rAlpha)
1838
1908
                --end
1839
1909
 
1840
1910
                vCounter[i] = vCounter[i] + 1
1987
2057
                        vCircX[i] = vCircX[i] + vCircDX[i]
1988
2058
                        vCircY[i] = vCircY[i] + vCircDY[i]
1989
2059
 
1990
 
                        if (CurrentHedgehog ~= nil) and (rAlpha ~= 255) then                    
1991
 
                                DoHorribleThings(i)--(i, g1X, g1Y, g2X, g2Y, dist)                              
 
2060
                        if (CurrentHedgehog ~= nil) and (rAlpha ~= 255) then
 
2061
                                DoHorribleThings(i)--(i, g1X, g1Y, g2X, g2Y, dist)
1992
2062
                        end
1993
2063
 
1994
2064
                end