-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatttir.lua
More file actions
1568 lines (1546 loc) · 58 KB
/
atttir.lua
File metadata and controls
1568 lines (1546 loc) · 58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local t={}--gestion du tir de projectile(soldat + tour)
if not functionload then
coattir=coroutine.create(function ()
local function anglebasic(x1,y1,actadvx,actadvy)--calcul de l'angle sans effet
local denom=mathsqrt((x1-actadvx)*(x1-actadvx)+(y1-actadvy)*(y1-actadvy))
if denom<0.05 and denom>=0 then
denom=0.05
elseif denom>-0.05 and denom<=0 then
denom=0.05
end
--angle de la trajectoire
local angle=math.acos((actadvx-x1)/denom)*180/3.14
if y1>actadvy then
angle=-angle
end
return angle
end
local function poussiereevenement(x,y,typepro)--effet de pousiere lorsqu'un boulet touche le sol(faudrai une image de pousiere(actuelement c'est l'image de l'ombre qui est utiliser))
if removepartiel1~=true and y<2048 and y>-2048 then
local poussiere=nil
local latransition=nil
-- local destructeurpartiel=function(obj)
-- group[obj.group]:remove(obj)
-- obj:removeSelf()
-- obj=nil
-- end
if typepro=="14" then
local poussiere1=nil
local metennoirlanim=function (obj)
obj:setFillColor(0.5)
end
poussiere1=display.newSprite(impro.explosion,impro.explosionseq)
if not goh then
poussiere1.xScale=0.8
else
poussiere1.xScale=0.2
end
poussiere1.yScale=poussiere1.xScale
poussiere1:setSequence("explosion")
--poussiere1:play()
poussiere1.alpha=0.7
poussiere1.x=x
if not goh then
local latransition1=transition.to(poussiere1,{delay=300*vitessejeuin,time=200*vitessejeuin,alpha=0,yScale=0.4,xScale=0.6,y=y+10,onComplete=destructeurpartieltran,onCancel=destructeurpartieltran,tag="elementtype",onStart=metennoirlanim})
poussiere1.y=y
if jeupause.etat==1 then
transition.pause(latransition1)
end
else
poussiere1.y=y-20
end
poussiere1.group=mathfloor(y+1024)
group[poussiere1.group]:insert(poussiere1)
spritegestion(poussiere1,1)
end
poussiere=display.newImage(impro.poussiere,1)
poussiere.xScale=0.01
local coefxscale=1
if typepro=="14" then
coefxscale=1.5
end
poussiere.yScale=poussiere.xScale
poussiere.alpha=0.8
poussiere.x=x
poussiere.y=y
latransition=transition.to(poussiere,{time=300*coefxscale*vitessejeuin,transition=easing.outQuad,alpha=0.5,xScale=0.14*coefxscale,yScale=0.14*coefxscale,y=y-10*coefxscale,onComplete=destructeurpartieltran,onCancel=destructeurpartieltran,tag="elementtype"})
--end
poussiere.group=mathfloor(y+1024)
group[poussiere.group]:insert(poussiere)
if jeupause.etat==1 then
transition.pause(latransition)
end
end
--transition.pause("elementtype")
--poussiere.pause1=0
--poussiere.cpt=0
--local function listpoussiere(event)
-- if removepartiel1==true then
-- if poussiere~=nil then
-- if poussiere.group~=nil and not removetotal then
-- group[poussiere.group]:remove(poussiere)
-- poussiere:removeSelf()
-- end
-- end
-- poussiere=nil
-- Runtime:removeEventListener( "enterFrame",listpoussiere)
-- elseif jeupause.etat==1 then--technique numero 3 de mise en pause(plus de probleme avec les processeurs mtk et probleme de deferencement)
-- if poussiere.pause1==0 then
-- poussiere.pause1=1
-- --if poussiere.actif==true then
-- --poussiere:pause()
-- --end
-- end
-- else
-- if poussiere.pause1==1 then
-- poussiere.pause1=0
-- --animliqobj.principale:play()
-- end
-- if poussiere.cpt<30 then
-- poussiere.xScale=poussiere.xScale+0.1
-- poussiere.yScale=poussiere.xScale
-- poussiere.y=poussiere.y-0.5
-- poussiere.alpha=poussiere.alpha-0.03
-- poussiere.cpt=poussiere.cpt+1
-- else
-- if poussiere~=nil then
-- if poussiere.group~=nil and not removetotal then
-- group[poussiere.group]:remove(poussiere)
-- poussiere:removeSelf()
-- end
-- end
-- poussiere=nil
-- Runtime:removeEventListener( "enterFrame",listpoussiere)
-- end
-- end
--end
--Runtime:addEventListener("enterFrame",listpoussiere)
end
function perteviepro(x,y,impact,attaquebase,orientation,numero,type1,pole)--demande que l'on enleve les vies d'un personnage
local cpt3=0
local attcptvar=1
local attaque=attaquebase
local mini=1
local maxi=nbsoldat
if orientation==1 then
mini=nbsoldatg
maxi=0
end
for i=mini,maxi do
--for i=1,nbsoldat,1 do
--print("pole "..pole.." i "..i.." pole "..isoldat[i].pole)
if isoldat[i].vivant and pole==isoldat[i].pole then -- orientation~=isoldat[i].orientation and -- and (zone1==isoldat[i].zone1 or zone2==isoldat[i].zone2) then
local distanceprosold
if goh then
distanceprosold=mathabs(x-(isoldat[i].x1+isoldat[i].centrex*isoldat[i].direction))+mathabs(y-(isoldat[i].y1+isoldat[i].centrey-isoldat[i].height*0.35))
else
distanceprosold=mathabs(x-(isoldat[i].x1+isoldat[i].centrex*isoldat[i].direction))+mathabs(y-(isoldat[i].y1+isoldat[i].centrey))
end
-- print("impact "..impact.." distanceprosold "..distanceprosold.." numero "..i)
if impact>distanceprosold then
if distanceprosold<1 then
distanceprosold=1
end
local attaquereel=mathfloor(attaque*(impact+3)/(impact+2*distanceprosold))
-- debut retourdinformation
if type1~=0 then
ibatiment[numero].vieenlever=ibatiment[numero].vieenlever+attaquereel
if isoldat[i].vie+5<isoldat[i].vietotale then
if true then -- issimulator then
if fpschoisicycle==0 and (fpschoisi<1.5 and isoldat[i].pole==0) then
local animsplashseq={name="levelup",
frames={2,3,4,5,5,5,5,5,5,5,5,5,5,5},--frames= {1,4,5,3}, -- frame indexes of animation, in image sheet
time = 500,
loopCount = 1, }
local animsplash=display.newSprite(imgbat.pique3,animsplashseq)
animsplash.x=isoldat[i].ombre.x
animsplash.y=isoldat[i].ombre.y-1
animsplash.xScale=0.15
animsplash.yScale=0.15
animsplash.fill.effect = "filter.brightness"
animsplash.fill.effect.intensity =0.6
animsplash:setFillColor(1,0,0)
animsplash.alpha=0.8
animsplash:setSequence("levelup")
spritegestion(animsplash,0)
animsplash.group=mathfloor(animsplash.y-9)+1024
group[animsplash.group]:insert(animsplash)
end
end
end
else
if isoldat[numero].orientation==0 then
--print("enleve vie de "..numero1.."de la part"..numero)
if isoldat[numero].classe<4 then
ibatiment[isoldat[numero].numbat].vieenlever=ibatiment[isoldat[numero].numbat].vieenlever+attaquereel--*fpschoisi
elseif isoldat[numero].classe<7 then
--vie enlever par le pv1
retinf.attpv1=retinf.attpv1+attaquereel--*fpschoisi
else
retinf.attgene=retinf.attgene+attaquereel--*fpschoisi
--vie enlever par le general
end
enlevevie(numero,attaquereel)
if isoldat[numero].typesoldat==172 then
local viemax=(isoldat[numero].level^0.75)*100
if viemax*5< isoldat[instance2.fin].vie then
local numnew=spawnsoldat(instance2.fin,isoldat[instance2.fin].typesoldat,nil,0)
convertunit(numnew)
local attaque=isoldat[instance2.fin].vietotale-isoldat[instance2.fin].vie
pertevie(numnew,attaque)
if isoldat[numnew].vie>viemax then
pertevie(numnew,isoldat[numnew].vie-viemax)
end
if goh then
animationlevelup(isoldat[numnew].x1+isoldat[numnew].centrex,isoldat[numnew].y1+isoldat[numnew].centrey-isoldat[numnew].height*0.35,3)
else
animationlevelup(isoldat[numnew].x1+isoldat[numnew].centrex,isoldat[numnew].y1+isoldat[numnew].centrey,3)
end
pertevie(instance2.fin,100000)
end
end
end
print("vie enlver par une unité atttir l82")
end
-- fin retourdinformation
--print("enleve les vies "..attaquereel)
pertevie(i,attaquereel)
-- print("attaque de "..attaquereel)
cpt3=cpt3+1
if cpt3>=4 then
attcptvar=attcptvar*0.9
if attcptvar<0.2 then
attcptvar=0.2
end
attaque=mathfloor(attaque*attcptvar)
cpt3=1
end
--print("impact"..(impact/(impact+2*distanceprosold)))
end
end
end
end
local function calculangle(type1,numero,x1,y1,tir,actadvx,actadvy,x2,y2,numfl,typetra)--calcul de l'angle avec effet(3D+tir en cloche avec ou sans portance)
--local actadvx=isoldat[numero1].x1
--local actadvy=isoldat[numero1].y1
--local x2=x1
--local y2=y1
--if type1==1 then
-- x2=ibatiment[numero].x+ibatiment[numero].xbase
-- y2=ibatiment[numero].y+ibatiment[numero].ybase
--end
local dist=nil
local distreel=nil
local denom=mathsqrt((x1-actadvx)*(x1-actadvx)+(y1-actadvy)*(y1-actadvy))
if denom<0.05 and denom>=0 then
denom=0.05
elseif denom>-0.05 and denom<=0 then
denom=0.05
end
--angle de la trajectoire
local angle=math.acos((actadvx-x1)/denom)*180/3.14
if y1>actadvy then
angle=-angle
end
--print("angle: "..angle)
dist=mathfloor(denom*26/(mathsqrt(20000)*tir.vitesse))
if type1==1 then
distreel=mathfloor(mathsqrt((x2-actadvx)*(x2-actadvx)+(y2-actadvy)*(y2-actadvy))*26/(mathsqrt(20000)*tir.vitesse))
else
distreel=dist
end
--print("instance2.dist ="..instance2.dist)
--angle de l'effet en cloche
local angle1=0
local angle2=0
local angleor=nil--angle d'origine de l'effet de la fleche
local testanglepoureffet=0
if angle>95 then
testanglepoureffet=1
elseif angle<85 and angle>-85 then
testanglepoureffet=1
elseif angle<-95 then
testanglepoureffet=1
end
local testangleeff=0
if typetra==2 or (typetra==1 and (typepro=="01" or typepro=="02" or typepro=="03")) then--(typetra)
testangleeff=1
elseif typetra==0 and typepro=="14" then--typepro~="14" then
testangleeff=1
end
--print("testanglepoureffet: "..testanglepoureffet.."testangleeff: "..testangleeff)
if (typetra~=1 or (typetra==1 and (typepro=="01" or typepro=="02" or typepro=="03"))) and testanglepoureffet==1 then-- testangleeff==1 and testanglepoureffet==1 then--(typetra==2 or (typetra==0 and typepro~="14")) and (angle>95 or (angle<85 and angle>-85) or angle<-95) then
--print("effet angle")
if dist>=35 then--distreel
angle2=45
elseif dist>=25 then
angle2=35
elseif dist>=15 then
angle2=25
elseif dist>=7 then
angle2=10
else
angle2=5
end
--angle2=45
local limmax=nil
if angle<85 and angle>-85 then
limmax=85
elseif angle>95 or angle<-95 then
limmax=95
end
if angle>limmax-5 then
angle2=0.5*angle2
elseif angle>limmax-5-10 then
angle2=0.7*angle2
elseif angle>limmax-5-20 then
angle2=0.8*angle2
elseif angle>limmax-5-30 then
angle2=0.9*angle2
end
if angle<85 and angle>=0 then
angle2=-angle2
--print("entre 60 et 0")
if angle+1*angle2>85 then
angle2=85-angle
end
elseif angle>-85 and angle<0 then
angle2=-angle2
--print("entre -60 et 0")
if angle+1*angle2>85 then
angle2=85-angle
end
elseif angle>95 then
angle2=angle2
--print("sup a 95")
if angle+1*angle2<95 then
angle2=95-angle
--print("correction")
end
elseif angle<-95 then
angle2=angle2
--print("inf a -120")
if angle+1*angle2>-95 then
angle2=-95-angle
end
end
angle1=angle1+1*angle2
end
local angle2pos=1
if angle2<0 then
angle2pos=-1
end
angleor=angle2
local tabtemp={}
tabtemp.angleor=angleor
tabtemp.angle=angle
tabtemp.angle2=angle2
tabtemp.testanglepoureffet=testanglepoureffet
tabtemp.dist=dist
tabtemp.distreel=distreel
tabtemp.angle2pos=angle2pos
if type1==0 then
isoldat[numero].tir.flecheinf[numfl]=tabtemp
if numfl==1 then -- and ibatiment[numero].type2==0 then
if actadvx>x1 then
if isoldat[numero].tir.bras.xscalepos==1 then
isoldat[numero].tir.bras.xScale=-1* isoldat[numero].tir.bras.xScale
isoldat[numero].tir.bras.xscalepos=-1
end
else
if isoldat[numero].tir.bras.xscalepos==-1 then
isoldat[numero].tir.bras.xScale=-1* isoldat[numero].tir.bras.xScale
isoldat[numero].tir.bras.xscalepos=1
end
end
--print("actu direction")
-- isoldat[numero].tir.bras:rotate(-isoldat[numero].tir.bras.angle)
-- isoldat[numero].tir.bras.angle=angle+1*angle2
-- isoldat[numero].tir.bras:rotate(isoldat[numero].tir.bras.angle)
end
else
if numfl==1 and goh and ibatiment[numero].type2<=1 then
if actadvx>x1 then
if ibatiment[numero].bras.xScale>0 then
ibatiment[numero].bras.xScale=-ibatiment[numero].bras.xScale
end
elseif ibatiment[numero].bras.xScale<0 then
ibatiment[numero].bras.xScale=-ibatiment[numero].bras.xScale
end
end
if numfl==1 and ibatiment[numero].type2==0 and ibatiment[numero].niveau~=4 and not goh then
ibatiment[numero].bras:rotate(-ibatiment[numero].bras.angle)-- a optimiser faire une seule rotation
-- local angleaction=0
-- if (angle2pos==1 and angle2>-10)or (angle2pos==-1 and angle2<10) then
-- angleaction=1
-- end
-- if angleaction~=0 then
-- angleaction=(-angle2pos*angleor*angleaction/dist*5)*1
-- end
-- print("angleaction"..angleaction)
ibatiment[numero].bras.angle=angle+1*angle2 -- +angleaction
if ibatiment[numero].bras.angle>90 then
ibatiment[numero].bras.yScale=-ibatiment[numero].bras.xScale
ibatiment[numero].bras.angle=ibatiment[numero].bras.angle+45
if ibatiment[numero].bras.angle<150 then
ibatiment[numero].bras.angle=150
end
else
ibatiment[numero].bras.yScale=ibatiment[numero].bras.xScale
if ibatiment[numero].bras.angle>30 then
ibatiment[numero].bras.angle=30
elseif ibatiment[numero].bras.angle<-120 then
ibatiment[numero].bras.angle=-140
elseif ibatiment[numero].bras.angle<-85 then
ibatiment[numero].bras.angle=-85
elseif ibatiment[numero].bras.angle<0 then
ibatiment[numero].bras.angle=ibatiment[numero].bras.angle+angle2
end
end
print("ibatiment[numero].bras.angle "..ibatiment[numero].bras.angle.." angle "..angle.." angle2 "..angle2)
-- print("ibatiment[numero].bras.angle "..ibatiment[numero].bras.angle)
-- if ibatiment[numero].bras.angle>225 and ibatiment[numero].bras.angle<270 then
-- ibatiment[numero].bras.angle=225
-- elseif ibatiment[numero].bras.angle<-225 and ibatiment[numero].bras.angle>-270 then
-- ibatiment[numero].bras.angle=-225
-- elseif ibatiment[numero].bras.angle<165 and ibatiment[numero].bras.angle>90 then
-- ibatiment[numero].bras.angle=165
-- elseif ibatiment[numero].bras.angle>45 and ibatiment[numero].bras.angle<90 then
-- ibatiment[numero].bras.angle=45
-- elseif ibatiment[numero].bras.angle<-45 and ibatiment[numero].bras.angle>-90 then
-- ibatiment[numero].bras.angle=-45
-- elseif ibatiment[numero].bras.angle>-165 and ibatiment[numero].bras.angle<-90 then
-- ibatiment[numero].bras.angle=-165
-- end
--print("ibatiment[numero].bras.angle1 "..ibatiment[numero].bras.angle)
ibatiment[numero].bras:rotate(ibatiment[numero].bras.angle)
end
ibatiment[numero].flecheinf[numfl]=tabtemp
end
end
function tirpro(type1,numero,x1,y1,numero1,numfl,sheet1,impact,orientation,x2,y2,typepro,typetra,tir,pole) --,zone1,zone2)--tir du projectile avec animation
--print("pole"..pole)
--local pause1=require("pause")
--local tir={}
--local orientation=0--x1 position du projectile
--local x2=x1--position de la base du soldat pour calculer la distance
--local y2=y1
--local typepro="01"--type de projectile
--local typetra=0--type de trajectoire 0 sans asservissement (boulet),1 vas sur la cible avec un leger asservissement, 2 asservissement totale
--local sheet1 =impro.projectiles
if goh then
if type1==1 then
if ibatiment[numero].type1==2 and ibatiment[numero].type2==1 then
affbrouillardglob(nil,x1,y1,ibatiment[numero].bras.numgroup+10,1,3)
-- affbrouillardglob(nil,x1,y1,nil)
-- affbrouillardglob(nil,x1,y1,nil)
end
end
end
sontirds=sontirds+1
if typetra==0 then
audio.play(son.combatcanon,{channel=mathrandom(15,19)})
else
local alea=mathrandom(3)
audio.play(son.combatarc[alea],{channel=alea+14})
end
local instance2 = display.newSprite( sheet1, sequence.tir )
local advx=nil--position de l'adversaire pour tir sans asservissement
local advy=nil
local cpt=0--compteur
local eftytra=0--contrer l'asservissement qui corrige l'effet
--local impact=0--rayon de l'impact
local ombre=nil--ombre du projectile
--print("numero1:"..numero1)
print("atttir 417 "..numero1)
local actadvx=isoldat[numero1].x1+isoldat[numero1].direction*isoldat[numero1].centrex
local actadvy
if goh then
actadvy=isoldat[numero1].y1+isoldat[numero1].centrey-isoldat[numero1].height*0.35
else
actadvy=isoldat[numero1].y1+isoldat[numero1].centrey
end
--local poussiere=nil
if typepro=="01" or typepro=="02" or typepro=="03" or typepro=="04" then
ombre=display.newImage(imbouton.ombrefl,1)
else
ombre=display.newImage(imbouton.ombrebou,1)
end
if typetra==1 or typetra==2 then--if type1==0 or (type1==1 and ibatiment[numero].type2==0) then
--ombre=display.newImage(imbouton.ombrefl,1)
else
advx=actadvx--isoldat[numero1].x1
advy=actadvy--isoldat[numero1].y1
--ombre=display.newImage(imbouton.ombrebou,1)
-- if poussiere==nil then
-- poussiere=display.newImage(impro.poussiere,1)
-- poussiere.isVisible=false
-- end
end
ombre.x=x2
ombre.y=y2
ombre.alpha=0.3
if typetra==1 then
ombre.alpha=0.3
ombre.xScale=0.3
ombre.yScale=0.3
else
ombre.alpha=0.3
ombre.xScale=0.5
ombre.yScale=0.5
end
group[2]:insert(ombre)
instance2:setSequence(typepro)
instance2.x = x1
instance2.y = y1
instance2.xScale = 0.15
if type1==0 then
instance2.xScale=isoldat[numero].tir.projscale
ombre.xScale=4*instance2.xScale
ombre.yScale=ombre.xScale
end
instance2.yScale=instance2.xScale
local trainee=display.newImage(impro.trainee,1)--display.newImage("batiment/projectiles/trainee.png",instance2.x,instance2.y)
trainee.x=instance2.x-0.05
trainee.y=instance2.y-0.05
trainee.xScale=instance2.xScale
trainee.yScale=instance2.yScale
--[[local denom=mathsqrt((x1-actadvx)^2+(y1-actadvy)^2)
if denom<0.05 and denom>=0 then
denom=0.05
elseif denom>-0.05 and denom<=0 then
denom=0.05
end
--angle de la trajectoire
local angle=math.acos((actadvx-x1)/denom)*180/3.14
if y1>isoldat[numero1].y1 then
angle=-angle
end
--print("angle: "..angle)
instance2.dist=mathfloor(denom*26/(mathsqrt(20000)*tir.vitesse))
if type1==1 then
instance2.distreel=mathfloor(mathsqrt((x2-actadvx)^2+(y2-actadvy)^2)*26/(mathsqrt(20000)*tir.vitesse))
else
instance2.distreel=instance2.dist
end
--print("instance2.dist ="..instance2.dist)
--angle de l'effet en cloche
local angle1=0
local angle2=0
local angleor=nil--angle d'origine de l'effet de la fleche
local testanglepoureffet=0
if angle>95 then
testanglepoureffet=1
elseif angle<85 and angle>-85 then
testanglepoureffet=1
elseif angle<-95 then
testanglepoureffet=1
end
local testangleeff=0
if typetra==2 then
testangleeff=1
elseif typetra==0 and typepro=="14" then--typepro~="14" then
testangleeff=1
end
--print("testanglepoureffet: "..testanglepoureffet.."testangleeff: "..testangleeff)
if typetra~=1 and testanglepoureffet==1 then-- testangleeff==1 and testanglepoureffet==1 then--(typetra==2 or (typetra==0 and typepro~="14")) and (angle>95 or (angle<85 and angle>-85) or angle<-95) then
--print("effet angle")
if instance2.dist>=35 then--distreel
angle2=45
elseif instance2.dist>=25 then
angle2=35
elseif instance2.dist>=15 then
angle2=25
elseif instance2.dist>=7 then
angle2=10
else
angle2=5
end
--angle2=45
local limmax=nil
if angle<85 and angle>-85 then
limmax=85
elseif angle>95 or angle<-95 then
limmax=95
end
if angle>limmax-5 then
angle2=0.5*angle2
elseif angle>limmax-5-10 then
angle2=0.7*angle2
elseif angle>limmax-5-20 then
angle2=0.8*angle2
elseif angle>limmax-5-30 then
angle2=0.9*angle2
end
if angle<85 and angle>=0 then
angle2=-angle2
--print("entre 60 et 0")
if angle+1*angle2>85 then
angle2=85-angle
end
elseif angle>-85 and angle<0 then
angle2=-angle2
--print("entre -60 et 0")
if angle+1*angle2>85 then
angle2=85-angle
end
elseif angle>95 then
angle2=angle2
--print("sup a 95")
if angle+1*angle2<95 then
angle2=95-angle
--print("correction")
end
elseif angle<-95 then
angle2=angle2
--print("inf a -120")
if angle+1*angle2>-95 then
angle2=-95-angle
end
end
angle1=angle1+1*angle2
end
local angle2pos=1
if angle2<0 then
angle2pos=-1
end
angleor=angle2]]
if type1==0 then
if typepro=="12" then
if isoldat[numero].gene==1 then
instance2:setFillColor(0,1,0)
end
end
end
if numfl~=1 then
calculangle(type1,numero,x1,y1,tir,actadvx,actadvy,x2,y2,numfl,typetra)
end
local angle=nil
local angleor=nil
local angle2=nil
local testanglepoureffet=nil
local angle2pos=nil
if type1==0 then
angle=isoldat[numero].tir.flecheinf[numfl].angle
angleor=isoldat[numero].tir.flecheinf[numfl].angleor
angle2=isoldat[numero].tir.flecheinf[numfl].angle2
testanglepoureffet=isoldat[numero].tir.flecheinf[numfl].testanglepoureffet
instance2.dist=isoldat[numero].tir.flecheinf[numfl].dist
instance2.distreel=isoldat[numero].tir.flecheinf[numfl].distreel
angle2pos=isoldat[numero].tir.flecheinf[numfl].angle2pos
else
angle=ibatiment[numero].flecheinf[numfl].angle
angleor=ibatiment[numero].flecheinf[numfl].angleor
angle2=ibatiment[numero].flecheinf[numfl].angle2
testanglepoureffet=ibatiment[numero].flecheinf[numfl].testanglepoureffet
instance2.dist=ibatiment[numero].flecheinf[numfl].dist
instance2.distreel=ibatiment[numero].flecheinf[numfl].distreel
angle2pos=ibatiment[numero].flecheinf[numfl].angle2pos
end
--print("angle2 :"..angle2.." angle: "..angle)
--necessaire angleor angle angle2 testanglepoureffet
ombre:rotate(angle)
instance2:rotate(angle+1*angle2)
trainee:rotate(angle+1*angle2)
group[2048]:insert(instance2)
group[2048]:insert(trainee)
instance2.gros=0
--instance2.cpt=0
instance2.fin=0--0 si pas fini si fini et pas de mec toucher -1 et sinon numero du mec toucher
instance2.pause1=0
instance2:play()
--constante de dep du pro sans asservissement
local depx=nil
local depy=nil
if typetra==0 then
depx=(advx-x1)/instance2.dist
depy=(advy-y1)/instance2.dist
end
--instance2.anframe=nil
instance2.fpschoisi=true --affichage effet
if fpschoisi>=2 then
instance2.fpschoisi=false
ombre.isVisible=false
trainee.isVisible=false
end
local function instance( event )
if removepartiel1==true then
group[2048]:remove( trainee )
trainee:removeSelf( )
instance2:pause()
Runtime:removeEventListener( "enterFrame",instance)
group[2048]:remove(instance2)
instance2:removeSelf( )
group[2]:insert(ombre)
ombre:removeSelf()
instance2=nil
trainee=nil
ombre=nil
else
if jeupause.etat==1 then--technique numero 3 de mise en pause(plus de probleme avec les processeurs mtk et probleme de deferencement)
if instance2.pause1==0 then
instance2.pause1=1
instance2:pause()
end
else
if instance2.pause1==1 then
instance2.pause1=0
instance2:play()
end
if true then
--if instance2.frame~=instance2.anframe then--if(event.phase=="loop")then
-- instance2.anframe=instance2.frame
--if instance2.pause1==0 then
if isoldat[numero1].vivant==true then
actadvx=isoldat[numero1].x1+isoldat[numero1].centrex*isoldat[numero1].direction
if goh then
actadvy=isoldat[numero1].y1+isoldat[numero1].centrey-isoldat[numero1].height*0.35
else
actadvy=isoldat[numero1].y1+isoldat[numero1].centrey
end
end
--deplacement du projectile
if typetra~=2 then
ancienx=instance2.x
ancieny=instance2.y
end
if typetra==0 then
cpt=cpt+1*fpschoisi --mdmoyennechosi
instance2:translate(depx*fpschoisi,depy*fpschoisi)
--instance2.x=instance2.x+depx*fpschoisi--26
--instance2.y=instance2.y+depy*fpschoisi--26
if instance2.fpschoisi then
ombre.x=instance2.x+depx+(x2-x1)*(instance2.dist-(cpt+1))/instance2.dist
ombre.y=instance2.y+depy+(y2-y1)*(instance2.dist-(cpt+1))/instance2.dist
end
elseif typetra==1 then
cpt=cpt+1*fpschoisi
instance2:translate((actadvx-x1)/instance2.dist*fpschoisi,(actadvy-y1)/instance2.dist*fpschoisi)
--instance2.x=instance2.x+(actadvx-x1)/instance2.dist*fpschoisi--26
--instance2.y=instance2.y+(actadvy-y1)/instance2.dist*fpschoisi--26
elseif typetra==2 then
cpt=cpt+1*fpschoisi
instance2.x=x1+cpt*(actadvx-x1)/instance2.dist
instance2.y=y1+cpt*(actadvy-y1)/instance2.dist
if instance2.fpschoisi then
ombre.x=x1+cpt*(actadvx-x1)/instance2.dist+(x2-x1)*(instance2.dist-cpt)/instance2.dist
ombre.y=y1+cpt*(actadvy-y1)/instance2.dist+(y2-y1)*(instance2.dist-cpt)/instance2.dist
end
end
if instance2.fpschoisi then
if typetra~=2 then
if typetra~=1 then
ombre:translate(instance2.x-ancienx,instance2.y-ancieny)
--ombre.x=ombre.x+instance2.x-ancienx
--ombre.y=ombre.y+instance2.y-ancieny
else
ombre.x=instance2.x+2
ombre.y=instance2.y+2
end
end
end
local calculdist1=(x1-actadvx)*(x1-actadvx)+(y1-isoldat[numero1].y1)*(y1-isoldat[numero1].y1)
--effet angle de la cloche
--effet cloche
if typretra==1 and (typepro~="01" or typepro~="02" or typepro~="03") then
local calculdist2=(instance2.x-actadvx)*(instance2.x-actadvx)+(instance2.y-actadvy)*(instance2.y-actadvy)
if calculdist1<calculdist2*2 then
--if instance2.cpt<instance2.dist/2 then
instance2.xScale=instance2.xScale+0.01
if numfl>=2 then
instance2:translate(-(numfl+1)*0.5,0)
-- instance2.x=instance2.x-(numfl+1)*0.5
end
else
instance2.xScale=instance2.xScale-0.01
if numfl>=2 then
instance2:translate((numfl-1)*0.5,0)
-- instance2.x=instance2.x+(numfl-1)*0.5
end
end
if instance2.xScale<0.15 then
instance2.xScale=0.15
end
end
if typetra==0 or typetra==2 or (typetra==1 and (typepro=="01" or typepro=="02" or typepro=="03")) then
local i=nil
if cpt<=instance2.dist/5 then
i=1
elseif cpt<=instance2.dist*2/5 then
i=2
elseif cpt<=instance2.dist*3/5 then
i=3
elseif cpt<=instance2.dist*4/5 then
i=4
else
i=5
end
if typetra==2 then
eftytra=eftytra+trajectoire.fle[i]*1
instance2.y=instance2.y+eftytra
instance2.xScale=instance2.xScale-trajectoire.fle[i]*0.01
else
instance2.y=instance2.y+trajectoire.boul[i]*1
instance2.xScale=instance2.xScale-trajectoire.boul[i]*0.01
end
if typetra~=1 and testanglepoureffet==1 then-- (typetra==2 or (typetra==0 and typepro~="14")) and (angle>95 or (angle<85 and angle>-85) or angle<-95) then
--print("correctif".."angle2pos: "..angle2pos.."angleor: "..angleor)
local angleaction=0
if (angle2pos==1 and angle2>-10)or (angle2pos==-1 and angle2<10) then
--if angle2>angle2pos*-10 then--regarde si l'angle est pos
--if angle2>-10 then
if typetra==2 then
angleaction=-trajectoire.fleangle[i]-- -trajectoire.fleangle[i]
else
angleaction=-trajectoire.boulangle[i]
end
if angle>90 or angle<-90 then
angleaction=-angleaction
end
--end
--else
-- if angle2<10 then
-- if typetra==2 then
-- angleaction=trajectoire.fleangle[i]
-- else
-- angleaction=trajectoire.boulangle[i]
-- end
-- end
end
if angleaction~=0 then
angleaction=-angle2pos*angleor*angleaction/instance2.dist*5
angle2=angle2+angleaction
--print("angle2 evol"..angle2.."rotate"..angleaction)
if typetra==2 or (typetra==0 and typepro=="14") or (typetra==1 and (typepro=="01" or typepro=="02" or typepro=="03")) then
instance2:rotate(angleaction)
end
if instance2.fpschoisi then
trainee:rotate(angleaction)
end
end
end
if typetra==0 and typepro~="14" then
instance2:rotate(5)
end
end
if instance2.fpschoisi then
trainee.y=instance2.y
trainee.x=instance2.x
instance2.yScale=instance2.xScale
trainee.xScale=instance2.xScale-0.05
trainee.yScale=instance2.xScale-0.05
end
--verification si le projectile est arrivé
if typetra==0 or typetra==2 then
if cpt>=instance2.dist then
if typetra==2 then
instance2.fin=numero1
--print("type2 ".. instance2.fin)
else
--print("pertevie"..pole)
perteviepro(instance2.x,instance2.y,impact,tir.attaque,orientation,numero,type1,pole)
-- for i=1,nbsoldat,1 do
-- if orientation~=isoldat[i].orientation and isoldat[i].vivant==true then
-- local distanceprosold=(instance2.x-isoldat[i].x1)^2+(instance2.y-isoldat[i].y1)^2
-- if impact>distanceprosold then
-- if distanceprosold<1 thenx
-- distanceprosold=1
-- end
-- pertevie(i,tir.attaque*impact/(impact+2*distanceprosold))
-- print("impact"..(impact/(impact+2*distanceprosold)))
-- end
-- end
-- end
instance2.fin=-1
if instance2.fpschoisi then
if instance2.y~=nil then
if typetra~=1 and typetra~=2 and type1~=0 then
-- local pousiere=nil
-- poussiere=display.newImage(impro.poussiere,1)
-- poussiere.isVisible=false
-- poussiere.x=instance2.x
-- poussiere.y=instance2.y
-- if instance2.y>=2048 or instance2.y<=-2048 then
-- --for i=0,100 do
-- --print("error nombre non reel")
-- --end
-- else
-- --print("instance2.y "..instance2.y)
-- poussiere.group=mathfloor(instance2.y+1024)
-- --print("poussiere group "..poussiere.group)
-- group[poussiere.group]:insert(poussiere)
-- poussiereevenement(poussiere)
poussiereevenement(instance2.x,instance2.y,typepro)
--end
end
else
--print("bug poussiere atttir 629")
end
end
end
end
elseif typetra==1 then
if mathabs(instance2.x-actadvx)+mathabs(instance2.y-actadvy)<15 then
if isoldat[numero1].vivant==true then
instance2.fin=numero1
--print("type1 ".. instance2.fin)
--pertevie(numero1,isoldat[numero].tir.attaque)
else
instance2.fin=-1
--print("type1".. instance2.fin)
end
elseif calculdist1<(instance2.x-x1)*(instance2.x-x1)+(instance2.y-y1)*(instance2.y-y1) then
local mini=1
local maxi=nbsoldat
if orientation==1 then
mini=nbsoldatg
maxi=0
end
for i=mini,maxi do
--for i=1,nbsoldat,1 do
if orientation~=isoldat[i].orientation and i~=numero1 and isoldat[i].vivant==true and pole==isoldat[i].pole then
if goh then
if 15>mathabs(instance2.x-(isoldat[i].x1+isoldat[i].direction*isoldat[i].centrex))+mathabs(instance2.y-(isoldat[i].y1+isoldat[i].centrey-isoldat[i].height*0.35)) then
instance2.fin=i
break
end
else
if 15>mathabs(instance2.x-(isoldat[i].x1+isoldat[i].direction*isoldat[i].centrex))+mathabs(instance2.y-(isoldat[i].y1+isoldat[i].centrey)) then
instance2.fin=i
break
end
end
end
end
if instance2.fin==0 then
instance2.fin=-1
end end end
if instance2.fin~=0 then
local etaitvivant=false
if instance2.fin~=-1 then
if isoldat[instance2.fin].vivant==true then
etaitvivant=true
--debut retourdinformation
if type1~=0 then
if ibatiment[numero]~=nil then -- condition suffisante a corriger le bug de revente de bat lorsque le pro et en l'air et que le tel lag a donf
ibatiment[numero].vieenlever=ibatiment[numero].vieenlever+tir.attaque
end
else
if isoldat[numero].orientation==0 then
--print("enleve vie de "..numero1.."de la part"..numero)
if isoldat[numero].classe<4 then
ibatiment[isoldat[numero].numbat].vieenlever=ibatiment[isoldat[numero].numbat].vieenlever+tir.attaque--*fpschoisi
elseif isoldat[numero].classe<7 then
--vie enlever par le pv1
retinf.attpv1=retinf.attpv1+tir.attaque--*fpschoisi
else
retinf.attgene=retinf.attgene+tir.attaque--*fpschoisi
--vie enlever par le general
end
enlevevie(numero,tir.attaque)
if isoldat[numero].typesoldat==172 then
local viemax=(isoldat[numero].level^0.75)*100
if viemax*5< isoldat[instance2.fin].vie then
local numnew=spawnsoldat(instance2.fin,isoldat[instance2.fin].typesoldat,nil,0)
convertunit(numnew)
local attaque=isoldat[instance2.fin].vietotale-isoldat[instance2.fin].vie
pertevie(numnew,attaque)
if isoldat[numnew].vie>viemax then
pertevie(numnew,isoldat[numnew].vie-viemax)
end
if goh then
animationlevelup(isoldat[numnew].x1+isoldat[numnew].centrex,isoldat[numnew].y1+isoldat[numnew].centrey-isoldat[numnew].height*0.35,3)
else
animationlevelup(isoldat[numnew].x1+isoldat[numnew].centrex,isoldat[numnew].y1+isoldat[numnew].centrey,3)
end
pertevie(instance2.fin,100000)
end
end
end
print("vie enlever par une unité atttir l747")
end
-- fin retourdinformation
pertevie(instance2.fin,tir.attaque,1)
end end
if instance2.fpschoisi then
local sheet2 =impro.projectiles1
sequence.tir.time=30
local instance3 = display.newSprite(sheet2,sequence.tir)
instance3:setSequence(typepro)
instance3.numero=instance2.fin
instance3.x = instance2.x
instance3.y = instance2.y
instance3.xScale=instance2.xScale
instance3.yScale=instance2.yScale
if type1==0 then
if typepro=="14" then
instance3:setFillColor(1,0,0)
instance3.xScale=instance3.xScale*0.4
instance3.yScale=instance3.yScale*0.4
end
end
if typepro=="01" or typepro=="02" or typepro=="03" or typepro=="04" then
instance3:rotate(angle)