Blitzmax vannilla problems

Started by Gijsdemik, March 03, 2023, 18:38:09

Previous topic - Next topic

Gijsdemik

Hey all,
I have isseus whit the orignal blitzmax.
I have code that alwayse worked fine.
but somehow i when i add new code in a total diffrant section of my game.
it causes the old code to act wierd and crasch on me.

now i have seen that there are many updates can some one tell me wy this happens.
For instance i have mines on my map, the code is not alterd and yet when i code
a new code in a section that has noting to do whit the mine code they still act wierd
and the crash report is terible it just says exception  would rater get the code line of the crash.

This bug is huning me big. i cant understand how code that has noting to do whit ohter functions
cause them to crash and act up. the mine code is just fine i use an array to set the object.
so if the array = 1 then do the mine on the map. the casting round i have has nothing to do whit that
but when i go next turn for two times all the mines get erased. there is no code to erase the maps mines
only a code that says if minegrid=1 then do mine.

I think something is wrong whit my blizmax i have seen it before when i program in a section
that has noting to do whit ohter sections it still screws it up.

i hope to get some help and i am thinking i migth need to update my blitzmax vannilla. altou that seems like long way to go

Amon

We're going to have to see the code dude. It could be something you're doing wrong or it could be vanilla blitzmax. Without some code I doubt anyone would be able to help you.

Gijsdemik

Well that is quite hard to get. but i can try.
Its just the my casting round has noting to do whit the placement of the mines on the map.
i use an array to load in my map. that says Mine=1 so place mine,
there is litary no code that says the mine=0 still when i adjust code somewhere else
mines dissapeare. until i re edit the code and remove it than its al good.
so i was thinking this strange behaviore is deu to blitzmax

Gijsdemik

So here is the code of the mines on the map.
If TakeObjectsA:Int[3,X,Y]=1  And MineGrid[X,Y]=0
  DrawImage arcaneT,Xi*50,Yi*50,Clock
EndIf

If TakeObjectsA:Int[3,X,Y]=1 And MineGrid[X,Y]=1
  DrawImage arcaneT2,Xi*50,Yi*50,Clock
EndIf

If TakeObjectsA:Int[3,X,Y]=1 And MineGrid[X,Y]=2
  DrawImage arcaneT3,Xi*50,Yi*50,Clock
EndIf
rem the taking of mines
If  TakeObjectsA:Int[3,X,Y]=1

If play=1 Then
If TakeObjectsA:Int[4,X,Y] <> Playertest
PlaySound Take;Play=0
EndIf
EndIf

If Playergrid[X,Y]>0 And TakeObjectsA:Int[3,X,Y]>0
TakeObjectsA:Int[4,X,Y]=Playergrid[X,Y]
EndIf
Else
EndIf
end rem
rem this function loads the array whit the mines.
Function loadMap:String()
Local SaveOrNot
Local path$

path$=RequestFile("Select a Folder","BWM")
SaveOrNot=Confirm("Are you sure You want to Load the map?");
If Saveornot=1
Local WriteMe$
Local Lt$
Local x;Local y;Local Z;Local Ly
Local File:TStream = OpenStream (path$)

'chek for mod file compare******************************************************
 
For X = 0 To 30 'from 25 to GridMax_X
For Y = 0 To 30  'from 12 to GridMax_Y


Local Gx:String =  ReadLine(File:TStream)+"~n"
Local VarbData:String
Local saz$[]=GX.split(",")

VarbData$=Saz:String

Local A=VarbData.ToInt:Int() 'Grid on
VarbData$=Saz:String[1]
Local Xd=VarbData.ToInt:Int() 'X
VarbData$=Saz:String[2]
Local Yd=VarbData.ToInt:Int() 'Y
VarbData$=Saz:String[3]
Local BuffStars=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[4]
Local Pickupsz=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[5]
Local WOtower=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[6]
Local WOMine=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[7]
Local Wallsz=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[8]
Local Floorsz=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[9]
Local PlayerStart=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[10]
Local Shirnes=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[11]
Local Foilage=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[12]
Local DoWolrdT=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[13]
Local Wiztower=VarbData.ToInt:Int() 'stars
Towerget[X,Y]=Wiztower
TeleportGrid[X,Y]=DoWolrdT
FoilGrid[X,Y]=Foilage 
FLGrid[Xd,Yd]=Floorsz
WizardPlayerStart[Xd,Yd]=PlayerStart
Ngrid[Xd,Yd]=Wallsz
Grid[Xd,Yd]=A
If A > 0
For Local DrX=0 To 4
For Local Dry= 0 To 4
RangeColGrid[Xd*5+Drx,Yd*5+Dry]=1
Next
Next
EndIf

Print "GRD "+A
Print "X "+Xd +" >>Xloop"+X
Print "Y"+Yd+ " >>Yloop"+Y
 
BuffArr[Xd,Yd]=BuffStars
PickthisupGrid[X,Y]=Pickupsz
TakeObjectsA[1,X,Y]=WOtower
TakeObjectsA[3,X,Y]=WOMine
  TakeObjectsA[5,X,Y]=Shirnes
 
Next
Next
 
CloseStream Fileend rem 'there is no code to remove mines when i run this it happens anyway
'i noticed on removing this code the bug does not happen that much
Case 1
'spelltest
If CountMouse_C=3 And WizardChosen=0 And ThisUnitCast=1
' If Mxs >= Wizx-CastRangeCreature And Mxs <= Wizx+CastRangeCreature And Mys>= Wizy-CastRangeCreature And Mys<= Wizy+CastRangeCreature
' If Playergrid[Mxs,Mys]<>Playertest And Playergrid[Mxs,Mys] > 0
' >>OVERRIDE BuffSpell:String[WichSpell,24]="8" 'Eff 1 ss "todo:: create internal spell buff for correct adding of external mod valeus. in test game this is fixed
'DrawText "unit may cast NOW" + CreatureSpell:String[LWichSpell,1],1100,500

Local CorX:Int=MouseX() /50*50/50
Local COrY:Int=MouseY() /50*50/50
If CorX < 1 Then CorX=0
If CorY < 1 Then CorY=0

DrawText "Corx   "+Corx+"CorY   "+CorY+"Xm   " + Xmove+"Ym   "+Ymove,100,500
 
MxsMove=Mxs
MysMove=Mys

Local zWizXMove=Wizx+Xmove+Xmove
Local zWizYmove=WizY+Ymove+Xmove

DrawText "WizXMove  "+zWizXMove+"WizYmove  "+zWizYmove,100,650

'If zWizXMove >= Mxs-CastRangeCreature And zWizXMove <= Mxs+CastRangeCreature And zWizYmove >= Mys-CastRangeCreature And zWizYmove<= Mys+CastRangeCreature
If zWizXMove >= Mxs+Xmove-CastRangeCreature And zWizXMove <= Mxs+Xmove+CastRangeCreature And zWizYmove >= Mys+Ymove-CastRangeCreature And zWizYmove<= Mys+Ymove+CastRangeCreature

DrawImage LSpellPic,CorX*50,COrY*50
EndIf 

If Shape=1

DrawImage LSpellPic,(Mxs-1)*50,Mys*50
DrawImage LSpellPic,(Mxs+1)*50,Mys*50
DrawImage LSpellPic,Mxs*50,(Mys-1)*50
DrawImage LSpellPic,Mxs*50,(Mys+1)*50
EndIf 

'EndIf
EndIf
'EndIf
If CountMouse_C=4 And WizardChosen=0 And ThisUnitCast=1
If Mxs >= Wizx-CastRangeCreature And Mxs <= Wizx+CastRangeCreature And Mys>= Wizy-CastRangeCreature And Mys<= Wizy+CastRangeCreature
If Playergrid[Mxs,Mys]=Playertest
' DrawText "unit cannot cast here",1100,500
LUnitselect=0
Countmouse_C=0
ThisUnitCast=0
PlaySound cantdo

EndIf
EndIf
EndIf

If CountMouse_C=4 And WizardChosen=0 And Playergrid[Mxs,Mys]<>Playertest And Playergrid[Mxs,Mys] > 0 And ThisUnitCast=1
If Mxs >= Wizx-CastRangeCreature And Mxs <= Wizx+CastRangeCreature And Mys>= Wizy-CastRangeCreature And Mys<= Wizy+CastRangeCreature

  Local ReadXC:String =CreatureSpell:String[LWichSpell,5]
Local Cst:Int=ReadXC.Toint()
Local ReadPwr:String = CreatureSpell:String[LWichSpell,24]
Local Pwr:Int=ReadPwr.Toint()
Print WizX
Print WizY

DoUnitPells Mxs,Mys,playertest,Cst,Pwr,WizX,WizY

PlaySound Magic
LUnitselect=0
Countmouse_C=0
ThisUnitCast=0
EndIf
EndIf

If CountMouse_C=4 And WizardChosen=0 And Playergrid[Mxs,Mys]=Playertest And ThisUnitCast=1
LUnitselect=0
Countmouse_C=0
ThisUnitCast=0
PlaySound cantdo
EndIf
'i afther calling this code, to create creaturse when i go to the next game round the mines dissapere.
 

If GaurdDo=0
If cast=2 And PlayerArray[PLayertest].MagicPoints =>ThisCrSpellCost And  PlayerArray[PLayertest].Concetration=>ThisSpellConcentration
If  DoThisCrSpell > 0 Then NewCRSpell = 1 makeCreature DoThisCrSpell,Playertest,Mxs+Xmove,Mys+Ymove,0  ; SetinfoString="New creature"
  PlayerArray[PLayertest].MagicPoints=PlayerArray[PLayertest].MagicPoints-ThisCrSpellCost
  PlayerArray[PLayertest].Concetration=PlayerArray[PLayertest].Concetration-ThisSpellConcentration
PlaySound Magic
cast=0
NewCRSpell=0
EndIf
EndIf

If GaurdDo=1
If cast=2 And PlayerArray[PLayertest].MagicPoints =>ThisCrSpellCost And  PlayerArray[PLayertest].Concetration=>ThisSpellConcentration And CellCheckNext(Mxs,Mys,PLayertest)=0
If  DoThisCrSpell > 0 Then NewCRSpell=1 makeCreature DoThisCrSpell,Playertest,Mxs+Xmove,Mys+Ymove,0  ; SetinfoString="New guard creature"
  PlayerArray[PLayertest].MagicPoints=PlayerArray[PLayertest].MagicPoints-ThisCrSpellCost
  PlayerArray[PLayertest].Concetration=PlayerArray[PLayertest].Concetration-ThisSpellConcentration
PlaySound Magic
cast=0
NewCRSpell=0
EndIf
EndIf
'makecreature makes the creature on the map and sets the array to the acoording object/creature. then when i enter
combat round the mines are gone.
'this is the combat round code
CheckTowers PLayertest
'DrawText Countmouse ,150,150
'timer stuff>

Global MYSGUI:Int
Global MXSGUI:Int
 mysgui=MouseY()/50*50/50 
 mxsgui=MouseX()/50*50/50

If MxsGui>=0 And MxsGui < 1 Then Xmove=Xmove-1
If MxsGui>=25 And MxsGui < 26 Then Xmove=Xmove+1
If MysGui>=0 And MYsGui < 1  Then Ymove=Ymove-1
If MYsGui>=15 And MysGui < 16 Then Ymove=Ymove+1

If KeyDown(Key_Left) Then Xmove=Xmove-1
If KeyDown(Key_Right) Then Xmove=Xmove+1
If KeyDown(Key_Up) Then Ymove=Ymove-1
If KeyDown(Key_Down) Then Ymove=Ymove+1
If Xmove < 0 Then Xmove = 0
If Ymove < 0  Then Ymove = 0
If Xmove > 12 Then Xmove = 12    ' 7 is 25 max
If Ymove > 15  Then Ymove = 15 ' 10 25 max.

'add grid shifter
Global XYGrid:Float[50,50]
Global XYP:Float[50,50]
For Local XT:Int=0 To 45
For Local YT:Int=0 To 45
Local Xti=XT-Xmove
Local Yti=YT-Ymove
If Xti < 1 Then Xti=0
If Yti < 1 Then Yti =0
XYGRID[Xti,Yti]=Grid[Xt,Yt]

If Grid[Xt,Yt] = 0 And Playergrid[Xt,YT] > 0 Xt=Xt+1 Yt=Yt+1

  If XYGRID[Xti,Yti] = 1 And Playergrid[XT,YT]=0
For Local DrX=0 To 4
For Local Dry= 0 To 4
RangeColGrid[Xti*5+Drx,Yti*5+Dry]=1
Next
Next
EndIf
  If XYGRID[Xti,Yti] = 0
For Local DrX=0 To 4
For Local Dry= 0 To 4
RangeColGrid[Xti*5+Drx,Yti*5+Dry]=0
Next
Next
EndIf
Next
Next

Global Speed:Int
Global Clock_9
Global Clock_16
Global Clock_12
Global Clock_6A
If EVENT_TIMERTICK speed=speed+1

If Speed=1 Clock_16=Clock_16+1
If Speed=1 Clock_12=Clock_12+1
If Speed=1 Clock_9=Clock_9+1
If speed=1 Clock_6A=Clock_6A+1
If Clock_12=12 Then Clock_12=0
If Clock_9=9 Then Clock_9=0
If Clock_16=16 Then Clock_16=0
If Clock_6A=6 Then Clock_6A=0
If Speed=2 Then Speed=0
'endtimer

If KeyHit(Key_p) Then PlayerArray[Playertest].PsdMod=2;PlayerArray[Playertest].BleedMod=2
If KeyDown(Key_Z) Then CheckRange()

SetScale(2,2)
Local MoveX:Int
Local MoveY:Int
Local yfix:Int
Local Xfix:Int
Local MXs= MouseX() /50
Local MYs= MouseY() /50

mx = MouseX() / TS
my = MouseY() / TS
 
Global SelectedObjectN:Int
Global SelectedObjectC:Int

  DrawMouseColorBox Mxsgui,Mysgui,0,0

Ybox=MYz
Xbox=MXz
  startx = Xbox/50
starty = Ybox/50
mx = Mxs   
my = mys 

TurnRound="Combat turn"
 Mxs=Mxs+Xmove
Mys=Mys+Ymove

Local MoveMouseX = Mxs
Local MoveMouseY = Mys
Global EnemyChose:Int
'************************************************************
Local ClickChek:Int
If CountMouse >=1 And MouseDown(2) = True Then Countmouse=0 ;SelectedObjectN= 0;PlaySound UndoSound ;EnemyChose=0;SelectedObjectC=0
If CountMouse >=5 Then Countmouse=0 ; EnemyChose=0
'**************************************

BuffBackground()
DrawWorld(Clock_6A)
DoWorldObjects Clock_9
DoWorldObjectsBack()
If KeyDown(KEY_I) Or MouseX()=>1000  And MouseY()=>500 Then DrawColorBox 1 ; DrawColorBox 2 ;DrawColorBox 3;DrawColorBox 4
DrawPlayer 1
Drawplayer 2
Drawplayer 3
DrawWizard 1
DrawWizard 2
DrawWizard 3
Drawplayer 4
DrawWizard 4

TakeFixedData Playertest
DrawPickUp Clock_16

DoWorldObjectsFrontB()
 
UpdateBonusStuff Clock_16
If KeyDown(Key_o)Then DrawRect PlayerArray[Playertest].x*50,PlayerArray[Playertest].y*50,25,25

If Not Playergrid[Mxs,Mys]=Null
GuiInformation(MXs,Mys)
EndIf

GuiInfoText Playertest
If ShowHelpers=1 Then CanDoaction Playertest,2,25
 DrawFog  Clock(),Clock_6(),Playertest
 
 
MZ PlayerTest
SetColor 256,256,256


 
 
'*****************************************************************
Global Sx:Int
Global Sy:Int
Sx=Mxs
Sy=Mys
Global EnemyX:Int
Global EnemyY:Int
Global FixedX:Int
Global FixedY:Int
Global BadGuy_X:Int=1
Global BadGuy_Y:Int=1
Global ClickX:Int
Global ClickY:Int
 
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Display damge
If MouseHit(1) And Countmouse < 3 Then CountMouse = CountMouse+1 ;TM=TM+1;  FlushMouse
'>>>>>>>>>>>>> OLD CHECK HERE
CheckXp playertest,CountMouse
If PAUSECOMBAT = 1

 CountMouse=0
EndIf
If PAUSECOMBAT = 0

'>>>>>>>>>>>>>Next turn
 
SetColor 215,50,0 ;
SetScale 1,1
Local NewFont:TImageFont = LoadImageFont(Mydirectory+"\Fnt\STCHARLE.ttf", 25,SMOOTHFONT )
SetImageFont NewFont
DrawText "Next phase"+Tm,1050,600 ;SetColor 255,255,255;SetScale 2,2
'If MouseX() < 1040 Then TM=0
If MouseX() > 1050 And MouseX()<1200 And MouseY()>600 And MouseY()<650 And TM > 1

If TM=1 Then Setinfostring="are you sure to go next phase?"
If TM=2 Then TurnCounter=TurnCounter+1 ; TM=0
If TM>2 Then tm=0
EndIf
 
If MouseX() > 1050 And MouseX()<1200 And MouseY()>600 And MouseY()<650
SetColor 215,215,125
SetScale 1,1 DrawText "Next phase"+Tm,1050,600 ;SetScale 2,2
SetColor 215,215,125
EndIf


'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>NEWCOMBAT
 If countmouse=1 And Playergrid[Mxs,Mys]=Playertest
FixedX=Mxs
FixedY=mys
SelectedObjectC=1
CountMouse=2
EndIf

If countmouse=1 And Playergrid[Mxs,Mys]<>Playertest Then Countmouse=0;EnemyChose=0;SelectedObjectN= 0;SelectedObjectC=0;Setinfostring="Not Your Ceature"';PlaySound NoMoveSound

If Countmouse=2 And FixedX > 0 And FixedY > 0
DrawImage MoveBox , FixedX*50,FixedY*50
If Playergrid[Mxs,Mys] = 0 Then GuiInformation FixedX,FixedY
EndIf



Global Click:Int=0
Global Hitdmg:Int=0
Global Hpx:Int
Global HPy:Int
Global EnemyObjectName:String
Global Atkamt:Int
Global Defamt:Int
Global TargetX:Int
Global TargetY:Int
Global GetCon:Int

If countmouse=>2 And Carr[GiveObecjtDataCell(Playertest,FixedX,FixedY),Playertest,FixedX,FixedY].BugRemove<>10 Or Playergrid[SX,SY] > 0 And Carr[GiveObecjtDataCell(GetPlayerFromCell (SX,SY),SX,SY),GetPlayerFromCell (SX,SY),SX,SY].BugRemove<>10
Countmouse=0
SelectedObjectN= 0
EnemyChose=0
SetinfoString="Bug"
SelectedObjectC=0
EndIf

If Not Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY]=Null MyRange=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].range
If TakeObjectsA:Int[2,FixedX,FixedY]=Playertest And TowerThingGrid:Int[FixedX,FixedY]=1 Then MyRange=MyRange+1
If fixedx > 0 And FixedY>0
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 DrawText "bonus",100,200
If EffectGrid[FixedX,FixedY] >= 1 And EffectGrid[FixedX,FixedY] <= 5 Then DrawText "Field BOnus",100,250
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 And EffectGrid[FixedX,FixedY] >= 1 And EffectGrid[FixedX,FixedY] <= 5  Then MyRange=Myrange+1
EndIf

If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].blessedd > 0 And  Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].blessingTypes=2 Then MyRange=Myrange+1

'tagrange
'DrawText "Number of attacks remaining = "+Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack,50, 650

Local Selectedunit:Int
If COuntmouse= 2 And Playergrid[FixedX,FixedY] = Playertest Then Selectedunit=1
If COuntmouse= 2 And Selectedunit = 0 And Playergrid[Mxs,Mys] <> Playertest countmouse=2;Setinfostring="Not Your Ceature";Selectedunit=0'PlaySound NoMoveSound
If COuntmouse=2 And Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].combat=1 PlaySound NoMoveSound countmouse=0;Setinfostring="Already had combat";Selectedunit=0
If Countmouse=2 And Playergrid[Mxs,Mys] <> Playertest And Playergrid[Mxs,mys] > 0
EnemyX=Mxs
EnemyY=Mys
SX=EnemyX
SY=EnemyY
EndIf



Local  NotMyPlayer = GetPlayerFromCell (SX,SY)
Local PlayerOncell=Playergrid[SX,SY]
Local hitpoints:Int=0
Local Canmove:Int=0
Local nameCr:String=""
Local GoodOrBad:String=""
Local CombatCheck:Int
Local AddSpider:Int

 


'If Not Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Combat=Null
 

'NEWBUG UPHERE>>
Local AtackSoundFx:Int
If Not Playergrid[FixedX,FixedY]=Null AtackSoundFx=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].SoundEffect
Global Subthisdmg:Int
 
If Countmouse=2 And FixedX > 0 And FixedY > 0

'If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 DrawText "bonus",100,200
'If EffectGrid[FixedX,FixedY] >= 1 Then DrawText "Field BOnus",100,250
'If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 And EffectGrid[FixedX,FixedY] >= 1 Then MyRange=Myrange+1
ShowBadguys(FixedX-Xmove,FixedY-Ymove,playertest,MyRange)
DrawText "x"+FixedX,100,100
DrawText "Y"+FixedY,100,150
 
EndIf
 
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>OLD DMG CHECK HERE

If Countmouse = 3  And Playergrid[Mxs,Mys]=0 Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="No one here";SelectedObjectC=0;CountMouse=0
If Countmouse = 3  And  Playergrid[SX,SY] = Playertest Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="Cannot Fight Self";SelectedObjectC=0;CountMouse=0



If Countmouse = 3  And CellDistanceOkeCheck(MyRange,FixedX,FixedY,SX,SY)=0 Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="Badguy is to far";SelectedObjectC=0;CountMouse=0
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Local FGrid:Float[500, 500]
Const TSf = 10
Local fx, fy
Local myf, mxf
Local startxf, startyf
 startxf = FixedX*5+2
 startyf = FixedY*5+2
Local i
Local z, g:Float



TPathfinderrange.SetUp(FGrid, 1, 0.1)
 
mxf = MouseX() / TSf
myf = MouseY() / TSf
mxf=Max(mxf,0); 'mx=Min(mx,29)
myf=Max(myf,0); 'my=Min(my,29)

'If MouseDown(1) Then Grid[mxf, myf] = 1


If Countmouse=>2 And MyRange > 1
If TPathfinderrange.FindPath(startxf , startyf , mxf, myf) Then

 
For i = 0 Until TPathfinderrange.Route.length Step 2
DrawRect TPathfinderrange.Route[i] * TSf , TPathfinderrange.Route[i + 1] * TSf ,5,5
If RangeColGrid[TPathfinderrange.Route[i] ,TPathfinderrange.Route[i + 1] ]=1
  If countmouse=3 Then Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="CannotShootTrougWall";SelectedObjectC=0;CountMouse=0
DrawText "Cannont Shoot",200,300
EndIf
Next
EndIf
EndIf
 
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>PStest
'combatz
If Countmouse = 3 And  Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Combat=1 PlaySound CantDo;EnemyChose=0;SetinfoString="Already had Combat";SelectedObjectC=0;Countmouse=0

If Countmouse = 3 And  Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack > 0 And Playergrid[Sx,Sy] > 0 And Playergrid[SX,Sy] <> playertest CountMouse=4;TargetX=Sx;TargetY=Sy

If Countmouse = 4
Local Muliatk:Int
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack > 1 Muliatk:Int=1 Else Muliatk=0

Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack-1

If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack= 0 Then Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Combat=1
GetCon=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Concetration
Local BleedRandom:Int
Local Dmg:Int
Local testDmg:Int
Local NewDmg:Int
  Local Penalty:Int
Local DoReSpawn:Int = Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].SpawnOnDead
atkamt=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].atk
defamt=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].def

Local BoostExp:Int=PlayerArray[Playertest].Expboost
Local AddExp:Int
Local Mtpexp:Int
Mtpexp=3
AddExp=Mtpexp*BoostExp


If Muliatk =1 Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp+Rnd(2)+2+AddExp
If Muliatk =0 Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp+Rnd(4)+4+AddExp



If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].VetLevel < 4

If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp >Rnd(4)+22
IncreaseVeterancy ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY

Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp=0
speech.speak(Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Name + " Has increased its level ")
EndIf
EndIf

'combateffect

SubThisdmg=defamt-atkamt
If Subthisdmg < 0 Then Subthisdmg = 0
 
Global BleedMOdadd:Int=PlayerArray[Playertest].BleedMod*5

If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].ImunetoBleed=0
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed = 1
BleedRandom=Rnd(24)+3+BleedMOdadd
If BleedRandom > 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=1
Setinfostring2="Target is wounded to bleed"

EndIf
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed = 2
BleedRandom=Rnd(20)+3+BleedMOdadd
If BleedRandom > 3 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=2
Setinfostring2="Target is more wounded to bleed"
EndIf

If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed => 1 And PlayerArray[Playertest].BleedMod = 2
BleedRandom=Rnd(20)+3+BleedMOdadd
If BleedRandom > 3 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=2
Setinfostring2="Target is more wounded to bleed"
EndIf 

If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed => 1 And PlayerArray[Playertest].BleedMod => 2
BleedRandom=Rnd(20)+3+BleedMOdadd
If BleedRandom > 3 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=3
Setinfostring2="Target is verry wounded to bleed"
EndIf 

Global CatchFIre:Int
Global PlayerFireIceLevel:Int
PlayerFireIceLevel=PlayerArray[Playertest].FireIceSkill
Global FCmod:Int
Global Fireadd:Int
If PlayerFireIceLevel=1 Then FCmod=3
If PlayerFireIceLevel=2 Then FCmod=6
If PlayerFireIceLevel=3 Then FCmod=9

If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=1
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn= 1 'And PlayerArray[Playertest].BleedMod => 2
CatchFIre=Rnd(20)+6
If CatchFIre> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=2 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel
Setinfostring2="Target on fire"
'remove ice x
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0

If PlayerFireIceLevel > 0
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-3
EndIf

EndIf 

If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=2
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn=1 'And PlayerArray[Playertest].BleedMod => 2
CatchFIre=Rnd(20)+10
If CatchFIre> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel

'remove ice
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0


If PlayerFireIceLevel > 0
FireAdd=4+Fcmod
EndIf

Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd


Setinfostring2="Target on fire 2"
EndIf 
EndIf
If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=1
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn=2 'And PlayerArray[Playertest].BleedMod => 2
CatchFIre=Rnd(20)+10
If CatchFIre> 8 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel

'remove ice
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0


If PlayerFireIceLevel > 0
FireAdd=6+Fcmod
EndIf

Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
Setinfostring2="Target on fire 3"
EndIf 
EndIf

If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=2
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn=2 'And PlayerArray[Playertest].BleedMod => 2
CatchFIre=Rnd(20)+15
If CatchFIre> 5 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel

'remove ice
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0


If PlayerFireIceLevel > 0
FireAdd=8+Fcmod
EndIf

Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
Setinfostring2="Target on fire 4"
EndIf 
     EndIf
Global Getfreezz:Int
If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=1
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce= 1 'And PlayerArray[Playertest].BleedMod => 2
Getfreezz=Rnd(20)+10
If Getfreezz> 12 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=2 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

Setinfostring2="Target on freezz"
'remove fire
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0


If PlayerFireIceLevel > 0
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-3
EndIf


EndIf 
EndIf
If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=2
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce=1 'And PlayerArray[Playertest].BleedMod => 2
Getfreezz=Rnd(20)+15
If Getfreezz> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

'remove fire
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0


If PlayerFireIceLevel > 0
FireAdd=3+Fcmod
EndIf

Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
Setinfostring2="Target on freezz2"
EndIf 
EndIf
If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=1
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce=2 'And PlayerArray[Playertest].BleedMod => 2
Getfreezz=Rnd(20)+10
If Getfreezz> 12 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

'remove fire
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0


If PlayerFireIceLevel > 0
FireAdd=6+Fcmod
EndIf

Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
Setinfostring2="Target on freezz3"
EndIf 
EndIf
If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=2
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce=2 'And PlayerArray[Playertest].BleedMod => 2
Getfreezz=Rnd(20)+15
If Getfreezz> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

'remove fire
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0


If PlayerFireIceLevel > 0
FireAdd=8+Fcmod
EndIf

Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
Setinfostring2="Target on freezz4"
EndIf 
EndIf



EndIf

EndIf
Local PLayerPoisonBuff:Int=PlayerArray[Playertest].PsdMod
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision > 0
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision+PLayerPoisonBuff =>Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].ImunetoPoison
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HasePoisoin=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision+PLayerPoisonBuff
Setinfostring2="Target is Poisoned"
Local PsDamage:Int=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision*3
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Hp-PsDamage
PlaySound Poisen
EndIf
EndIf
'dmg test
  Penalty = Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].RangePenalty
DmG =GetDmgFromCreature(ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY)





testDmg=GetDmgFromCreature(ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY)
Local BalnaceDmg:Int
BalnaceDmg=Dmg/4

If Muliatk =1 Dmg=Dmg/2+BalnaceDmg       ; Print "Damge Modifer you did > "+DMG + "instead of "+testDmg
   If Muliatk= 0  Dmg=Dmg ; Print "Damge you did > "+DMG


PlayerArray[Playertest].PlayerExp=PlayerArray[Playertest].PlayerExp+2+DmG/3







Local Domod:Int=SubthisDmg/2
Local TotalDmg=Dmg-DoMod
If TotalDmg =< 2 Then TotalDmg = 2
'If TotalDmg > 8 Then PlayerArray[PLayertest].MagicPoints=PlayerArray[playertest].MagicPoints+1
If MyRange=1 NewDmg = TotalDmg
If MyRange=1 And Penalty=1 NewDmg = TotalDmg/2
Local RangeBalance:Int
'Range Mod
If MyRange > 2 RangeBalance=TotalDmg/3
'If MyRange > 1 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=0 NewDmg=TotalDmg



'If MyRange > 1 And Penalty=1 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg/2;Notify "Dmg reduced "+TotalDmg/2
'If MyRange > 1 And Penalty=0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg
        
If MyRange > 1 And Penalty=0 And CellCheckNext(FixedX,FixedY,Playertest)=1 NewDmg=TotalDmg
If GetCon < 7
  If MyRange > 1  And CellDistanceOkeCheck(2,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg ';Notify "DMG 1  "+ NewDmg
   If MyRange > 2  And CellDistanceOkeCheck(2,FixedX,FixedY,Sx,Sy)=0 If CellDistanceOkeCheck(MyRange,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg-RangeBalance ';Notify "DMG 2   "+NewDmg+" Old "+TotalDmg
     If MyRange > 1 And Penalty=1 And CellCheckNext(FixedX,FixedY,Playertest)=1 NewDmg=TotalDmg/2;DoTextOnce1 FixedX*50,FixedY*50+10,35,"Penalty!",1;
EndIf
If GetCon >= 7

If MyRange > 1 NewDmg=TotalDmg

EndIf
If NewDmg < 0 Then NewDmg = 2


Hitpoints = Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp

   If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield > 0 And NewDmg < 10
NewDmg=0
speech.speak("Damage bloked by shield")
Local RandomRemove:Int=Rnd(20)
If RandomRemove=>10
speech.speak("Shield is destroyed")
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield-1
PlaySound ShieldDown
EndIf
EndIf

If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield > 0 And NewDmg => 10
NewDmg=0
speech.speak("Shield is destroyed")
Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield-1
PlaySound ShieldDown
EndIf





Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Hitpoints-NewDmg
 

CanMove = Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].move
Hpx=SX
HPy=SY

  Hitpoints=Hitpoints-NewDmg

Global unitisgier:Int=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gierattak
  If unitisgier=1 And Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp <12
Hitpoints=Hitpoints-12
Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp+12
Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax+2
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp > Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax
Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax
EndIf
EndIf


Hitdmg=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp
EnemyObjectName:String=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Name
SubThisdmg=NewDmg

Local IsWizard=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Is_wizzard
Local AmiWizard=Carr[ObjectGridRefRance[Playergrid[FixedX,FixedY],FixedX,FixedY],Playergrid[FixedX,FixedY],FixedX,FixedY].Is_wizzard

Local PlayerOwn=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Player
Local DeadFx=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].DeadSound
 
Local GetZxp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].cost/2
Local GetEXp=5+GetZxp

If IsWizard= 0


If Hitpoints =< 0 Then PlayerArray[PLayertest].PlayerExp=PlayerArray[PLayertest].PlayerExp+GetExp;DrawText "You gained "+ GetExp +"Exp",100,400
If CanMove  >0
'deadcr
If IsWizard= 0 And AmiWizard=0 And Hitpoints =< 0 And MyRange = 1 And DoReSpawn = 0 Then DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy
If IsWizard= 0 And AmiWizard=0 And Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].SpawnOnDead=0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy

If IsWizard= 0 And AmiWizard=1 And Hitpoints =< 0 And MyRange = 1 And DoReSpawn = 0 Then DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy;TakeObject Sx,Sy,1
If IsWizard= 0 And AmiWizard=1 And Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].SpawnOnDead=0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy;TakeObject Sx,Sy,1 
 


If Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=0 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx]

EndIf

If CanMove= 0
If Hitpoints =< 0 And MyRange = 1 And DoReSpawn = 0 Then DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx]
   If Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx]
If Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=0 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ; PlaySound FX_DEAD[DeadFx]

EndIf

   If Hitpoints =< 0  And DoReSpawn > 1
Local Playerwas:Int=Playergrid[SX,SY]
  DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy)
PlaySound FX_DEAD[DeadFx];
PlaySound revive
makecreature DoReSpawn,Playerwas,Sx,Sy,0
Do=1;Dofx=4
   EndIf


Setinfostring = "Badguy has "+ Hitpoints + " hp" + "You did "+NewDmg+" Damage"

EndIf

If IsWizard= 1
Local EnemyWizPoints=PlayerArray[PlayerOwn].MagicPoints/2+8+Rnd(10) 'added +8+rnd--
Local WizExp=25+15*PlayerArray[PlayerOwn].Playerlevel

If Hitpoints =< 0 Then WizardIsDead PlayerOwn,SX,SY;PlayerGameOver[PlayerOwn]=1; PlaySound FX_DEAD[1]
If Hitpoints =< 0 Then PlayerArray[PLayertest].MagicPoints=PlayerArray[playertest].MagicPoints+EnemyWizPoints
     If Hitpoints =<0 Then PlayerArray[PLayertest].PlayerExp=PlayerArray[PLayertest].PlayerExp+WizExp
If Hitpoints =< 0 Then setinfostring2="You got a piece of " +PlayerArray[PlayerOwn].Name+" magic points "+EnemyWizPoints+ " MagicPoints "
If Hitpoints =< 0 Then Setinfostring="You gained [ "+ WizExp +" Exp"

  EndIf
PlaySound FX_ATK[AtackSoundFx]
  DoTextInfo=1
CountMouse=5
EndIf
If DoTextInfo=1 And Hitdmg > 0 Then DoTextOnce1 Hpx*50,Hpy*50-10,35,"HP= ["+Hitdmg+"] Dmg= "+SubThisdmg,1
If DoTextInfo=1 And Hitdmg < 1 Then DoTextOnce1 Hpx*50,Hpy*50-10,35,"dead",1



If Do= 1 Then Do=DO+1
If DO=2 Then CountT8=0 Do=3
If DO=3 Then DoMeOnce TargetX,TargetY,FrmMax[DoFx],DoFx
If CountT8 = FrmMax[DoFx]-1 Then DO=0




'OLD DMG>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Local DMGlow:Int=1
Local DMGHigh:Int=1
Local CombDmg:Int=1

'************************************************************************************************************************************************
If KeyHit(KEY_Z) Then chosen=Chosen+1
If chosen = 2 Then chosen = 0
ChekBattle playertest,GiveObecjtData(playertest),chosen
If Initstuff=2 Then Initstuff=0
intstatusmouse=0
 
 For Local Xp= 0 To 49
For Local Yp= 0 To 49
For Local PLn= 0 To  AmountOfPlayers
If Not Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp]=Null
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=1
DrawImage CrPosioonInfo,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=2
DrawImage CrPosioonInfo2,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=3
DrawImage CrPosioonInfo3,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=>4
DrawImage CrPosioonInfo4,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=1
DrawImage BleedPic,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=2
DrawImage BleedPic2,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=>3
DrawImage BleedPic3,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].BurnTurns=>1
DrawImage CrBurn,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Iceturns=>1
DrawImage Crice,Xp*50,Yp*50
EndIf



If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].VetLevel =1
DrawImage Vetrancey,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].VetLevel =2
DrawImage Vetrancey,Xp*50,Yp*50
DrawImage Vetrancey,Xp*50+7,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].VetLevel =>3
DrawImage Vetrancey,Xp*50,Yp*50
DrawImage Vetrancey,Xp*50+7,Yp*50
DrawImage Vetrancey,Xp*50+14,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Shield=1
DrawImage ShieldB,Xp*50,Yp*50,Clock_6A
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Shield=2
DrawImage ShieldC2,Xp*50,Yp*50,Clock_6A
EndIf



EndIf
If Not Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp]=Null
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=1 And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=2  And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50-10
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=3  And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50-20
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=4  And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50-30
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=5
DrawImage MaxBuff,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Blessedd >=1
DrawImage Blessed,Xp*50,Yp*50
EndIf


EndIf

Next
Next
Next
EndIf ' ENDXPCHECK
'So the isseu is that i change code and stuff that has noting to do whit these functions wich where working fine before.
there is no remove mines code and the rest should not get affected by adding or chaning the spellcast round.


Midimaster

#4
first view:

1.
The code has problems in Vanilla, because the REM command has no END REM. In my IDE the whole code gets commented out because of this!

2.
Switch the IDE to DEBUG MODE... so you will get detailed informations about a bug and not only the "exception" message.

3.
I would guess that something like a missing audio file or data fle is the reason and not your game logic

4.
There is a CASE command without the corresponding SELECT command in your code.

5.
there are RETURNs in your comments, that causes new lines in the IDE and the compiler mis-interprets this as code lines.

6.
Is this really the complete code? Where are the definitions of variables like:

Global TakeObjectsA:Int[3,3,3]
Global MineGrid[X,Y]

...

7.
There are "FUNCTION" code lines without corresponding END FUNCTION code line ...


You have code line mosters like this:
For Local Xp= 0 To 49
For Local Yp= 0 To 49
For Local PLn= 0 To  AmountOfPlayers
If Not Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp]=Null
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=1
DrawImage CrPosioonInfo,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=2
DrawImage CrPosioonInfo2,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=3
DrawImage CrPosioonInfo3,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=>4
DrawImage CrPosioonInfo4,Xp*50,Yp*50
EndIf
 
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=1
DrawImage BleedPic,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=2
DrawImage BleedPic2,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=>3
DrawImage BleedPic3,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].BurnTurns=>1
DrawImage CrBurn,Xp*50,Yp*50
EndIf
...followed by 200 similar lines...

you should re-structure them and divide it in smaller function calls like this:

For Local Xp:Int= 0 To 49
    For Local Yp:Int= 0 To 49
        For Local PLn:Int= 0 To  AmountOfPlayers
            CheckCarrObject PLn,Xp,Yp
        Next
    Next
Next
   
Function CheckCarrObject Carr[P:Int, X:Int, Y,Int]
    Local CarrObject:TCarr = Carr[ObjectGridRefRance[P,X,Y],P,X,Y]
    If CarrObject= Null Return

    X = X*50
    Y = Y*50
    Select CarrObject.HasePoisoin
        Case 1
            DrawImage CrPosioonInfo , X,Y
        Case 2
            DrawImage CrPosioonInfo2, X,Y
        Case 3
            '....
        Case 4
    End Select


    Select CarrObject.HaseBleed
        Case 1
       
        Case 2
   
End Function
...back from Egypt

Gijsdemik

#5
Thanks you for your respond.

I might have to trim down some code but this is my first game every,
I got down to the isseus if i use this the combat phase code my mines get deleted.
i tested my game and it finnaly runs whit out errors.
its wierd because there is no line that says remove grids it just say if mine[X,Y]=1 make mine.
if i use this then my mines dissparea.
and you said its a loading probllem but all assests get loaded before the rest of the code.
everything runs fine until i hit this code.

Case 2
'TurnC
CheckTowers PLayertest
'DrawText Countmouse ,150,150
'timer stuff>

Global MYSGUI:Int
Global MXSGUI:Int
mysgui=MouseY()/50*50/50 
mxsgui=MouseX()/50*50/50

If MxsGui>=0 And MxsGui < 1 Then Xmove=Xmove-1
If MxsGui>=25 And MxsGui < 26 Then Xmove=Xmove+1
If MysGui>=0 And MYsGui < 1  Then Ymove=Ymove-1
If MYsGui>=15 And MysGui < 16 Then Ymove=Ymove+1

If KeyDown(Key_Left) Then Xmove=Xmove-1
If KeyDown(Key_Right) Then Xmove=Xmove+1
If KeyDown(Key_Up) Then Ymove=Ymove-1
If KeyDown(Key_Down) Then Ymove=Ymove+1
If Xmove < 0 Then Xmove = 0
If Ymove < 0  Then Ymove = 0
If Xmove > 12 Then Xmove = 12    ' 7 is 25 max
If Ymove > 15  Then Ymove = 15 ' 10 25 max.

'add grid shifter
Global XYGrid:Float[50,50]
Global XYP:Float[50,50]
For Local XT:Int=0 To 45
For Local YT:Int=0 To 45
        Local Xti=XT-Xmove
        Local Yti=YT-Ymove
            If Xti < 1 Then Xti=0
            If Yti < 1 Then Yti =0
            XYGRID[Xti,Yti]=Grid[Xt,Yt]

If     Grid[Xt,Yt] = 0 And Playergrid[Xt,YT]    >    0    Xt=Xt+1 Yt=Yt+1

             If     XYGRID[Xti,Yti] = 1 And Playergrid[XT,YT]=0
                    For Local DrX=0 To 4   
                     For Local Dry= 0 To 4
                    RangeColGrid[Xti*5+Drx,Yti*5+Dry]=1
                    Next
                    Next
            EndIf     
             If     XYGRID[Xti,Yti] = 0
                    For Local DrX=0 To 4   
                     For Local Dry= 0 To 4
                    RangeColGrid[Xti*5+Drx,Yti*5+Dry]=0
                    Next
                    Next
            EndIf     
Next
Next

Global Speed:Int
Global Clock_9
Global Clock_16
Global Clock_12
Global Clock_6A
If EVENT_TIMERTICK speed=speed+1

If Speed=1 Clock_16=Clock_16+1
If Speed=1 Clock_12=Clock_12+1
If Speed=1 Clock_9=Clock_9+1
If speed=1 Clock_6A=Clock_6A+1
If Clock_12=12 Then Clock_12=0
If Clock_9=9 Then Clock_9=0
If Clock_16=16 Then Clock_16=0
If Clock_6A=6 Then Clock_6A=0
If Speed=2 Then Speed=0
'endtimer

If KeyHit(Key_p) Then PlayerArray[Playertest].PsdMod=2;PlayerArray[Playertest].BleedMod=2
If KeyDown(Key_Z) Then CheckRange()

SetScale(2,2)
Local MoveX:Int
Local MoveY:Int
Local yfix:Int
Local Xfix:Int
Local MXs=    MouseX() /50
Local MYs=    MouseY() /50

    mx = MouseX() / TS
    my = MouseY() / TS

Global SelectedObjectN:Int
Global SelectedObjectC:Int

  DrawMouseColorBox Mxsgui,Mysgui,0,0

    Ybox=MYz
    Xbox=MXz
         startx = Xbox/50
        starty = Ybox/50
    mx = Mxs       
    my = mys 
     
TurnRound="Combat turn"
Mxs=Mxs+Xmove
Mys=Mys+Ymove

Local MoveMouseX = Mxs
Local MoveMouseY = Mys
Global EnemyChose:Int
'************************************************************
Local ClickChek:Int
If CountMouse >=1 And MouseDown(2) = True Then Countmouse=0 ;SelectedObjectN= 0;PlaySound UndoSound ;EnemyChose=0;SelectedObjectC=0
If CountMouse >=5 Then Countmouse=0 ; EnemyChose=0
'**************************************

BuffBackground()
DrawWorld(Clock_6A)
DoWorldObjects Clock_9
DoWorldObjectsBack()
If KeyDown(KEY_I) Or MouseX()=>1000  And MouseY()=>500 Then DrawColorBox 1 ; DrawColorBox 2 ;DrawColorBox 3;DrawColorBox 4   
DrawPlayer 1
Drawplayer 2
Drawplayer 3
DrawWizard 1
DrawWizard 2
DrawWizard 3
Drawplayer 4
DrawWizard 4

TakeFixedData Playertest
DrawPickUp Clock_16

DoWorldObjectsFrontB()

UpdateBonusStuff Clock_16
If KeyDown(Key_o)Then DrawRect PlayerArray[Playertest].x*50,PlayerArray[Playertest].y*50,25,25

If Not Playergrid[Mxs,Mys]=Null
GuiInformation(MXs,Mys)
EndIf

GuiInfoText Playertest
If ShowHelpers=1 Then CanDoaction Playertest,2,25
DrawFog  Clock(),Clock_6(),Playertest
 

    MZ PlayerTest
    SetColor 256,256,256
   


 
'*****************************************************************
Global Sx:Int
Global Sy:Int
Sx=Mxs
Sy=Mys
Global EnemyX:Int
Global EnemyY:Int
Global FixedX:Int
Global FixedY:Int
Global BadGuy_X:Int=1
Global BadGuy_Y:Int=1
Global ClickX:Int
Global ClickY:Int

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Display damge
If MouseHit(1) And Countmouse < 3 Then CountMouse = CountMouse+1 ;TM=TM+1;  FlushMouse
'>>>>>>>>>>>>>        OLD CHECK HERE
CheckXp playertest,CountMouse
If PAUSECOMBAT = 1

CountMouse=0
EndIf
If PAUSECOMBAT = 0

'>>>>>>>>>>>>>Next turn

SetColor 215,50,0 ;
SetScale 1,1
Local NewFont:TImageFont = LoadImageFont(Mydirectory+"\Fnt\STCHARLE.ttf", 25,SMOOTHFONT )
SetImageFont NewFont   
DrawText "Next phase"+Tm,1050,600 ;SetColor 255,255,255;SetScale 2,2
'If MouseX() < 1040 Then TM=0
If MouseX() > 1050 And MouseX()<1200 And MouseY()>600 And MouseY()<650 And TM > 1

If TM=1 Then Setinfostring="are you sure to go next phase?"
If TM=2 Then TurnCounter=TurnCounter+1 ; TM=0
If TM>2 Then tm=0
EndIf

If MouseX() > 1050 And MouseX()<1200 And MouseY()>600 And MouseY()<650
SetColor 215,215,125
SetScale 1,1 DrawText "Next phase"+Tm,1050,600 ;SetScale 2,2
SetColor 215,215,125
EndIf


'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>NEWCOMBAT
If countmouse=1 And Playergrid[Mxs,Mys]=Playertest
FixedX=Mxs
FixedY=mys
SelectedObjectC=1
CountMouse=2
EndIf

If countmouse=1 And Playergrid[Mxs,Mys]<>Playertest Then Countmouse=0;EnemyChose=0;SelectedObjectN= 0;SelectedObjectC=0;Setinfostring="Not Your Ceature"';PlaySound NoMoveSound

If Countmouse=2 And FixedX > 0 And FixedY > 0
DrawImage MoveBox , FixedX*50,FixedY*50
If Playergrid[Mxs,Mys] = 0 Then GuiInformation FixedX,FixedY
EndIf



Global Click:Int=0
Global Hitdmg:Int=0
Global Hpx:Int
Global HPy:Int
Global EnemyObjectName:String
Global Atkamt:Int
Global Defamt:Int
Global TargetX:Int
Global TargetY:Int
Global GetCon:Int

If countmouse=>2 And Carr[GiveObecjtDataCell(Playertest,FixedX,FixedY),Playertest,FixedX,FixedY].BugRemove<>10 Or Playergrid[SX,SY] > 0 And Carr[GiveObecjtDataCell(GetPlayerFromCell (SX,SY),SX,SY),GetPlayerFromCell (SX,SY),SX,SY].BugRemove<>10
Countmouse=0
SelectedObjectN= 0
EnemyChose=0
SetinfoString="Bug"
SelectedObjectC=0
EndIf

If Not Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY]=Null MyRange=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].range
If TakeObjectsA:Int[2,FixedX,FixedY]=Playertest And TowerThingGrid:Int[FixedX,FixedY]=1 Then MyRange=MyRange+1
If fixedx > 0 And FixedY>0
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 DrawText "bonus",100,200
If EffectGrid[FixedX,FixedY] >= 1 And EffectGrid[FixedX,FixedY] <= 5 Then DrawText "Field BOnus",100,250
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 And EffectGrid[FixedX,FixedY] >= 1 And EffectGrid[FixedX,FixedY] <= 5  Then MyRange=Myrange+1
EndIf

If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].blessedd > 0 And  Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].blessingTypes=2 Then MyRange=Myrange+1

'tagrange
'DrawText "Number of attacks remaining = "+Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack,50, 650

Local Selectedunit:Int
If COuntmouse= 2 And Playergrid[FixedX,FixedY] = Playertest Then Selectedunit=1
If COuntmouse= 2 And Selectedunit = 0 And Playergrid[Mxs,Mys] <> Playertest countmouse=2;Setinfostring="Not Your Ceature";Selectedunit=0'PlaySound NoMoveSound
If COuntmouse=2 And Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].combat=1 PlaySound NoMoveSound countmouse=0;Setinfostring="Already had combat";Selectedunit=0
If Countmouse=2 And Playergrid[Mxs,Mys] <> Playertest And Playergrid[Mxs,mys] > 0
EnemyX=Mxs
EnemyY=Mys
SX=EnemyX
SY=EnemyY
EndIf



Local  NotMyPlayer = GetPlayerFromCell (SX,SY)
Local PlayerOncell=Playergrid[SX,SY]
Local hitpoints:Int=0
Local Canmove:Int=0
Local nameCr:String=""
Local GoodOrBad:String=""
Local CombatCheck:Int
Local AddSpider:Int




'If Not Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Combat=Null


'NEWBUG UPHERE>>
Local AtackSoundFx:Int
If Not Playergrid[FixedX,FixedY]=Null AtackSoundFx=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].SoundEffect
Global Subthisdmg:Int

If Countmouse=2 And FixedX > 0 And FixedY > 0

'If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 DrawText "bonus",100,200
'If EffectGrid[FixedX,FixedY] >= 1 Then DrawText "Field BOnus",100,250
'If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Uniteffectgrid=1 And EffectGrid[FixedX,FixedY] >= 1 Then MyRange=Myrange+1
ShowBadguys(FixedX-Xmove,FixedY-Ymove,playertest,MyRange)
DrawText "x"+FixedX,100,100
DrawText "Y"+FixedY,100,150

EndIf

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>OLD DMG CHECK HERE

If Countmouse = 3  And Playergrid[Mxs,Mys]=0 Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="No one here";SelectedObjectC=0;CountMouse=0
If Countmouse = 3  And  Playergrid[SX,SY] = Playertest Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="Cannot Fight Self";SelectedObjectC=0;CountMouse=0



If Countmouse = 3  And CellDistanceOkeCheck(MyRange,FixedX,FixedY,SX,SY)=0 Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="Badguy is to far";SelectedObjectC=0;CountMouse=0
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Local FGrid:Float[500, 500]
Const TSf = 10
Local fx, fy
Local myf, mxf
Local startxf, startyf
startxf = FixedX*5+2
startyf = FixedY*5+2
Local i
Local z, g:Float



TPathfinderrange.SetUp(FGrid, 1, 0.1)

    mxf = MouseX() / TSf
    myf = MouseY() / TSf
    mxf=Max(mxf,0); 'mx=Min(mx,29)
    myf=Max(myf,0); 'my=Min(my,29)

    'If MouseDown(1) Then Grid[mxf, myf] = 1
   
   
If Countmouse=>2 And MyRange > 1   
    If TPathfinderrange.FindPath(startxf , startyf , mxf, myf) Then


        For i = 0 Until TPathfinderrange.Route.length Step 2
            DrawRect TPathfinderrange.Route[i] * TSf , TPathfinderrange.Route[i + 1] * TSf ,5,5
            If RangeColGrid[TPathfinderrange.Route[i] ,TPathfinderrange.Route[i + 1] ]=1
             If countmouse=3 Then Countmouse=0 ;SelectedObjectN= 0 ;PlaySound CantDo;EnemyChose=0;SetinfoString="CannotShootTrougWall";SelectedObjectC=0;CountMouse=0
            DrawText "Cannont Shoot",200,300
            EndIf
        Next
    EndIf
EndIf     

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>PStest
'combatz
If Countmouse = 3 And  Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Combat=1 PlaySound CantDo;EnemyChose=0;SetinfoString="Already had Combat";SelectedObjectC=0;Countmouse=0

If Countmouse = 3 And  Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack > 0 And Playergrid[Sx,Sy] > 0 And Playergrid[SX,Sy] <> playertest CountMouse=4;TargetX=Sx;TargetY=Sy

If Countmouse = 4
Local Muliatk:Int
If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack > 1 Muliatk:Int=1 Else Muliatk=0

    Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack-1

        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].TimesAttack= 0 Then Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Combat=1
GetCon=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Concetration
                Local BleedRandom:Int
                Local Dmg:Int
                Local testDmg:Int
                Local NewDmg:Int
                 Local Penalty:Int
                Local DoReSpawn:Int = Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].SpawnOnDead
                atkamt=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].atk
                defamt=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].def
           
                Local BoostExp:Int=PlayerArray[Playertest].Expboost
                Local AddExp:Int
                Local Mtpexp:Int
                Mtpexp=3
                AddExp=Mtpexp*BoostExp
       
           
                If Muliatk =1     Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp+Rnd(2)+2+AddExp
                If Muliatk =0     Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp+Rnd(4)+4+AddExp
                                           
       
       
                If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].VetLevel < 4
       
                If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp >Rnd(4)+22
                IncreaseVeterancy ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY
               
                Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gotexp=0
                speech.speak(Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Name + " Has increased its level ")
                EndIf
                EndIf
               
                'combateffect

                SubThisdmg=defamt-atkamt
                If Subthisdmg < 0 Then Subthisdmg = 0
         
                    Global BleedMOdadd:Int=PlayerArray[Playertest].BleedMod*5
               
                    If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].ImunetoBleed=0
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed = 1
                        BleedRandom=Rnd(24)+3+BleedMOdadd
                        If BleedRandom > 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=1
                        Setinfostring2="Target is wounded to bleed"
                   
                        EndIf
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed = 2
                        BleedRandom=Rnd(20)+3+BleedMOdadd
                        If BleedRandom > 3 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=2
                        Setinfostring2="Target is more wounded to bleed"
                        EndIf         
                       
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed => 1 And PlayerArray[Playertest].BleedMod = 2
                        BleedRandom=Rnd(20)+3+BleedMOdadd
                        If BleedRandom > 3 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=2
                        Setinfostring2="Target is more wounded to bleed"
                        EndIf 
                       
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBleed => 1 And PlayerArray[Playertest].BleedMod => 2
                        BleedRandom=Rnd(20)+3+BleedMOdadd
                        If BleedRandom > 3 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HaseBleed=3
                        Setinfostring2="Target is verry wounded to bleed"
                        EndIf 
                       
                        Global CatchFIre:Int
                        Global PlayerFireIceLevel:Int
                        PlayerFireIceLevel=PlayerArray[Playertest].FireIceSkill
                        Global FCmod:Int
                        Global Fireadd:Int
                        If PlayerFireIceLevel=1 Then FCmod=3
                        If PlayerFireIceLevel=2 Then FCmod=6
                        If PlayerFireIceLevel=3 Then FCmod=9
                                               
                    If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=1
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn= 1 'And PlayerArray[Playertest].BleedMod => 2
                        CatchFIre=Rnd(20)+6
                        If CatchFIre> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=2 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel
                        Setinfostring2="Target on fire"
                        'remove ice x
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0
                       
                            If PlayerFireIceLevel > 0
                            Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-3
                            EndIf
                           
                        EndIf 
                       
                    If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=2
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn=1 'And PlayerArray[Playertest].BleedMod => 2
                        CatchFIre=Rnd(20)+10
                        If CatchFIre> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel

                                'remove ice
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0
                       

                            If PlayerFireIceLevel > 0
                            FireAdd=4+Fcmod
                            EndIf

                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
                       

                        Setinfostring2="Target on fire 2"
                        EndIf 
                    EndIf   
                        If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=1
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn=2 'And PlayerArray[Playertest].BleedMod => 2
                        CatchFIre=Rnd(20)+10
                        If CatchFIre> 8 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel

                                'remove ice
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0
                       

                                    If PlayerFireIceLevel > 0
                                    FireAdd=6+Fcmod
                                    EndIf

                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
                        Setinfostring2="Target on fire 3"
                        EndIf 
                    EndIf
                       
                    If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].burnType=2
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoBurn=2 'And PlayerArray[Playertest].BleedMod => 2
                        CatchFIre=Rnd(20)+15
                        If CatchFIre> 5 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnLevel=PlayerFireIceLevel

                            'remove ice
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=0
                       

                                If PlayerFireIceLevel > 0
                                    FireAdd=8+Fcmod
                                    EndIf

                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
                        Setinfostring2="Target on fire 4"
                        EndIf 
                     EndIf
                                    Global Getfreezz:Int
                    If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=1
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce= 1 'And PlayerArray[Playertest].BleedMod => 2
                        Getfreezz=Rnd(20)+10
                        If Getfreezz> 12 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=2 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

                        Setinfostring2="Target on freezz"
                            'remove fire
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0
                       

                                If PlayerFireIceLevel > 0
                            Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-3
                            EndIf

                       
                        EndIf 
                    EndIf     
                    If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=2
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce=1 'And PlayerArray[Playertest].BleedMod => 2
                        Getfreezz=Rnd(20)+15
                        If Getfreezz> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

                            'remove fire
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0
                       

                            If PlayerFireIceLevel > 0
                                    FireAdd=3+Fcmod
                                    EndIf

                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
                        Setinfostring2="Target on freezz2"
                        EndIf 
                    EndIf     
                        If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=1
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce=2 'And PlayerArray[Playertest].BleedMod => 2
                        Getfreezz=Rnd(20)+10
                        If Getfreezz> 12 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

                            'remove fire
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0
                       

                                If PlayerFireIceLevel > 0
                                    FireAdd=6+Fcmod
                                    EndIf

                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
                        Setinfostring2="Target on freezz3"
                        EndIf 
                    EndIf     
                    If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].IceType=2
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].DoIce=2 'And PlayerArray[Playertest].BleedMod => 2
                        Getfreezz=Rnd(20)+15
                        If Getfreezz> 10 Then Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Iceturns=3 ; Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Icelevel=PlayerFireIceLevel

                            'remove fire
                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].BurnTurns=0
                       

                                If PlayerFireIceLevel > 0
                                    FireAdd=8+Fcmod
                                    EndIf

                        Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp-FireAdd
                        Setinfostring2="Target on freezz4"
                        EndIf 
                    EndIf     

                   

                    EndIf

                    EndIf   
                    Local PLayerPoisonBuff:Int=PlayerArray[Playertest].PsdMod
                    If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision > 0
                        If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision+PLayerPoisonBuff =>Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].ImunetoPoison
                            Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].HasePoisoin=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision+PLayerPoisonBuff
                            Setinfostring2="Target is Poisoned"
                                Local PsDamage:Int=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].CanDoPoision*3
                                Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Hp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Hp-PsDamage
                            PlaySound Poisen
                            EndIf
                    EndIf       
                    'dmg test
                 Penalty = Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].RangePenalty
                DmG =GetDmgFromCreature(ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY)


               
                 
               
                testDmg=GetDmgFromCreature(ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY)
                Local BalnaceDmg:Int
                BalnaceDmg=Dmg/4

                If Muliatk =1 Dmg=Dmg/2+BalnaceDmg       ; Print "Damge Modifer you did > "+DMG + "instead of "+testDmg
               If Muliatk= 0  Dmg=Dmg             ; Print "Damge you did > "+DMG

   
                PlayerArray[Playertest].PlayerExp=PlayerArray[Playertest].PlayerExp+2+DmG/3
           
               
       
                                   
   
       
                 
            Local Domod:Int=SubthisDmg/2
            Local TotalDmg=Dmg-DoMod
            If TotalDmg =< 2 Then TotalDmg = 2                 
            'If TotalDmg > 8 Then PlayerArray[PLayertest].MagicPoints=PlayerArray[playertest].MagicPoints+1
            If MyRange=1 NewDmg = TotalDmg     
            If MyRange=1 And Penalty=1 NewDmg = TotalDmg/2     
            Local RangeBalance:Int
            'Range Mod
            If MyRange > 2 RangeBalance=TotalDmg/3
            'If MyRange > 1 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=0 NewDmg=TotalDmg
             

       
            'If MyRange > 1 And Penalty=1 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg/2;Notify "Dmg reduced "+TotalDmg/2
            'If MyRange > 1 And Penalty=0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg     
         
             If MyRange > 1 And Penalty=0 And CellCheckNext(FixedX,FixedY,Playertest)=1 NewDmg=TotalDmg
            If GetCon < 7     
             If MyRange > 1  And CellDistanceOkeCheck(2,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg ';Notify "DMG 1  "+ NewDmg
           If MyRange > 2  And CellDistanceOkeCheck(2,FixedX,FixedY,Sx,Sy)=0 If CellDistanceOkeCheck(MyRange,FixedX,FixedY,Sx,Sy)=1 NewDmg=TotalDmg-RangeBalance ';Notify "DMG 2   "+NewDmg+" Old "+TotalDmg
            If MyRange > 1 And Penalty=1 And CellCheckNext(FixedX,FixedY,Playertest)=1 NewDmg=TotalDmg/2;DoTextOnce1 FixedX*50,FixedY*50+10,35,"Penalty!",1;
            EndIf
            If    GetCon >= 7
           
                 If MyRange > 1 NewDmg=TotalDmg
           
            EndIf
            If NewDmg < 0 Then NewDmg = 2
           
                 
            Hitpoints =    Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp       
           
           If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield > 0 And NewDmg < 10
            NewDmg=0
            speech.speak("Damage bloked by shield")
            Local RandomRemove:Int=Rnd(20)
                If RandomRemove=>10
                speech.speak("Shield is destroyed")
                Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield-1
                PlaySound ShieldDown
                EndIf
            EndIf                 
           
            If Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield > 0 And NewDmg => 10
            NewDmg=0
            speech.speak("Shield is destroyed")
            Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Shield-1
                PlaySound ShieldDown
            EndIf           



           
                       
            Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp=Hitpoints-NewDmg

           
            CanMove = Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].move
            Hpx=SX
            HPy=SY
   
             Hitpoints=Hitpoints-NewDmg
                   
            Global unitisgier:Int=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].Gierattak
             If unitisgier=1 And Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp <12
            Hitpoints=Hitpoints-12
            Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp+12
            Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax+2
                If Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp > Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax
                Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hp=Carr[ObjectGridRefRance[Playertest,FixedX,FixedY],Playertest,FixedX,FixedY].hpmax
                EndIf
            EndIf
   

            Hitdmg=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].hp
            EnemyObjectName:String=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Name
            SubThisdmg=NewDmg
           
            Local IsWizard=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Is_wizzard
            Local AmiWizard=Carr[ObjectGridRefRance[Playergrid[FixedX,FixedY],FixedX,FixedY],Playergrid[FixedX,FixedY],FixedX,FixedY].Is_wizzard

            Local PlayerOwn=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].Player
            Local DeadFx=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].DeadSound

            Local GetZxp=Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].cost/2
            Local GetEXp=5+GetZxp           

            If IsWizard= 0
           
       
            If Hitpoints =< 0 Then PlayerArray[PLayertest].PlayerExp=PlayerArray[PLayertest].PlayerExp+GetExp;DrawText "You gained "+ GetExp +"Exp",100,400
            If CanMove  >0
            'deadcr
            If IsWizard= 0 And AmiWizard=0 And Hitpoints =< 0 And MyRange = 1 And DoReSpawn = 0 Then DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy)    ; PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy
            If IsWizard= 0 And AmiWizard=0 And Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].SpawnOnDead=0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ;    PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy
       
            If IsWizard= 0 And AmiWizard=1 And Hitpoints =< 0 And MyRange = 1 And DoReSpawn = 0 Then DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy)    ; PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy;TakeObject Sx,Sy,1
            If IsWizard= 0 And AmiWizard=1 And Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And Carr[ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],Playergrid[SX,Sy],SX,SY].SpawnOnDead=0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ;    PlaySound FX_DEAD[DeadFx];CopyCreatures ObjectGridRefRance[Playertest,FixedX,FixedY],playertest,FixedX,FixedY,Sx,Sy;TakeObject Sx,Sy,1     
             
   

            If Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=0 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ;    PlaySound FX_DEAD[DeadFx]           

            EndIf
       
            If CanMove= 0
            If Hitpoints =< 0 And MyRange = 1 And DoReSpawn = 0 Then DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ;    PlaySound FX_DEAD[DeadFx]
               If Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=1 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ;    PlaySound FX_DEAD[DeadFx]
            If Hitpoints =< 0 And MyRange > 1 And DoReSpawn = 0 And CellDistanceOkeCheck(1,FixedX,FixedY,Sx,Sy)=0 DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy) ;    PlaySound FX_DEAD[DeadFx]           

            EndIf
           
               If Hitpoints =< 0  And DoReSpawn > 1
            Local Playerwas:Int=Playergrid[SX,SY]
             DeadCreature(ObjectGridRefRance[Playergrid[Sx,Sy],Sx,SY],PlayerGrid[Sx,Sy],Sx,Sy)   
            PlaySound FX_DEAD[DeadFx];
            PlaySound revive
            makecreature DoReSpawn,Playerwas,Sx,Sy,0
                Do=1;Dofx=4       
               EndIf

         
            Setinfostring = "Badguy has "+ Hitpoints + " hp" + "You did "+NewDmg+" Damage"
           
            EndIf
           
            If IsWizard= 1
            Local EnemyWizPoints=PlayerArray[PlayerOwn].MagicPoints/2+8+Rnd(10) 'added +8+rnd--
            Local WizExp=25+15*PlayerArray[PlayerOwn].Playerlevel
           
                If Hitpoints =< 0 Then WizardIsDead PlayerOwn,SX,SY;PlayerGameOver[PlayerOwn]=1;    PlaySound FX_DEAD[1]
                If Hitpoints =< 0 Then PlayerArray[PLayertest].MagicPoints=PlayerArray[playertest].MagicPoints+EnemyWizPoints
                 If Hitpoints =<0 Then PlayerArray[PLayertest].PlayerExp=PlayerArray[PLayertest].PlayerExp+WizExp
                If Hitpoints =< 0 Then setinfostring2="You got a piece of " +PlayerArray[PlayerOwn].Name+" magic points "+EnemyWizPoints+ " MagicPoints "
                If Hitpoints =< 0 Then Setinfostring="You gained [ "+ WizExp +" Exp"
       
             EndIf   
            PlaySound FX_ATK[AtackSoundFx]
             DoTextInfo=1
            CountMouse=5
            EndIf
            If DoTextInfo=1 And Hitdmg > 0 Then DoTextOnce1 Hpx*50,Hpy*50-10,35,"HP= ["+Hitdmg+"] Dmg= "+SubThisdmg,1
             If DoTextInfo=1 And Hitdmg < 1 Then DoTextOnce1 Hpx*50,Hpy*50-10,35,"dead",1

       

            If Do= 1 Then Do=DO+1
            If DO=2 Then CountT8=0 Do=3
            If DO=3 Then DoMeOnce TargetX,TargetY,FrmMax[DoFx],DoFx
            If CountT8 = FrmMax[DoFx]-1 Then DO=0
   
     
                 

'OLD DMG>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Local DMGlow:Int=1
Local DMGHigh:Int=1
Local CombDmg:Int=1

'************************************************************************************************************************************************
If KeyHit(KEY_Z) Then chosen=Chosen+1
If chosen = 2 Then chosen = 0
ChekBattle playertest,GiveObecjtData(playertest),chosen
If Initstuff=2 Then Initstuff=0
intstatusmouse=0

For Local Xp= 0 To 49
For Local Yp= 0 To 49
For Local PLn= 0 To  AmountOfPlayers
If Not Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp]=Null
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=1
DrawImage CrPosioonInfo,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=2
DrawImage CrPosioonInfo2,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=3
DrawImage CrPosioonInfo3,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HasePoisoin=>4
DrawImage CrPosioonInfo4,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=1
DrawImage BleedPic,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=2
DrawImage BleedPic2,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].HaseBleed=>3
DrawImage BleedPic3,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].BurnTurns=>1
DrawImage CrBurn,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Iceturns=>1
DrawImage Crice,Xp*50,Yp*50
EndIf



If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].VetLevel =1
DrawImage Vetrancey,Xp*50,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].VetLevel =2
DrawImage Vetrancey,Xp*50,Yp*50
DrawImage Vetrancey,Xp*50+7,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].VetLevel =>3
DrawImage Vetrancey,Xp*50,Yp*50
DrawImage Vetrancey,Xp*50+7,Yp*50
DrawImage Vetrancey,Xp*50+14,Yp*50
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Shield=1
DrawImage ShieldB,Xp*50,Yp*50,Clock_6A
EndIf
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Shield=2
DrawImage ShieldC2,Xp*50,Yp*50,Clock_6A
EndIf



EndIf
If Not Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp]=Null
If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=1 And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=2  And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50-10
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=3  And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50-20
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=4  And Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff < 5
DrawImage Buffed,Xp*50,Yp*50-30
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Buff >=5
DrawImage MaxBuff,Xp*50,Yp*50
EndIf

If Carr[ObjectGridRefRance[PLn,Xp,Yp],PLn,Xp,Yp].Blessedd >=1
DrawImage Blessed,Xp*50,Yp*50
EndIf


EndIf

Next
Next
Next
EndIf ' ENDXPCHECK

End Select




i know i am not good at coding and i wil add your changes to my code what i dont get is that this code hase been fine for years.
if you want i can share all the mine code. but its a lot. i reverted my programm and got down to the isseus in the combatphase (case2) i started back on an old cold wich runs fine. i noticed this bug before when i am programming a section that has noting to do whit someting else it still crashes the game. then when i remove my new code all is fine eventough i never coded anything to interupt the old code. i am gonna adjust my game to you code i never knew that it should be done that way if you need more dependant code i can send it but its gonna be a lot.
Bellow here are the ohter depantacies of the code for the mines.
Function loadMap:String()
Local SaveOrNot
Local path$

path$=RequestFile("Select a Folder","BWM")
SaveOrNot=Confirm("Are you sure You want to Load the map?");
If Saveornot=1
Local WriteMe$
Local Lt$
Local x;Local y;Local Z;Local Ly
Local File:TStream = OpenStream (path$)   

'chek for mod file compare******************************************************

For X = 0 To 30        'from 25 to GridMax_X
    For Y = 0 To 30              'from 12 to GridMax_Y


Local Gx:String =  ReadLine(File:TStream)+"~n"
Local VarbData:String
Local saz$[]=GX.split(",")

VarbData$=Saz:String

Local A=VarbData.ToInt:Int() 'Grid on
VarbData$=Saz:String[1]
Local Xd=VarbData.ToInt:Int() 'X
VarbData$=Saz:String[2]
Local Yd=VarbData.ToInt:Int() 'Y
VarbData$=Saz:String[3]
Local BuffStars=VarbData.ToInt:Int() 'stars
VarbData$=Saz:String[4]
Local Pickupsz=VarbData.ToInt:Int() 'pickups
VarbData$=Saz:String[5]
Local WOtower=VarbData.ToInt:Int() 'towers
VarbData$=Saz:String[6]
Local WOMine=VarbData.ToInt:Int() 'Mines
VarbData$=Saz:String[7]
Local Wallsz=VarbData.ToInt:Int() 'Walls
VarbData$=Saz:String[8]
Local Floorsz=VarbData.ToInt:Int() 'Backdrops
VarbData$=Saz:String[9]
Local PlayerStart=VarbData.ToInt:Int() 'Player go
VarbData$=Saz:String[10]
Local Shirnes=VarbData.ToInt:Int() 'BUff
VarbData$=Saz:String[11]
Local Foilage=VarbData.ToInt:Int() 'Random stuff
VarbData$=Saz:String[12]
Local DoWolrdT=VarbData.ToInt:Int() 'World objects
VarbData$=Saz:String[13]
Local Wiztower=VarbData.ToInt:Int() 'Magic towers
    Towerget[X,Y]=Wiztower
    TeleportGrid[X,Y]=DoWolrdT
    FoilGrid[X,Y]=Foilage     
    FLGrid[Xd,Yd]=Floorsz
    WizardPlayerStart[Xd,Yd]=PlayerStart
    Ngrid[Xd,Yd]=Wallsz
    Grid[Xd,Yd]=A
    If A > 0
        For Local DrX=0 To 4
        For Local Dry= 0 To 4
        RangeColGrid[Xd*5+Drx,Yd*5+Dry]=1
        Next
        Next
    EndIf   

    Print "GRD "+A
    Print "X "+Xd +" >>Xloop"+X
    Print "Y"+Yd+ " >>Yloop"+Y

    BuffArr[Xd,Yd]=BuffStars
    PickthisupGrid[X,Y]=Pickupsz
    TakeObjectsA[1,X,Y]=WOtower
    TakeObjectsA[3,X,Y]=WOMine
    TakeObjectsA[5,X,Y]=Shirnes

    Next
    Next

CloseStream File
Else
If Saveornot=0 Notify("No save done")
EndIf
       
The mine array selft is heavey used if you wish i can share that code but is gonna be alot TakeObjectsA[3,X,Y].
THe mines are set here TakeObjectsA[3,X,Y] > 0
what i dont understand is i have removed all the editd code to the combat phase including shifting the world
the orginal game was based on a field of 19x 15Y and i changed that to 30,30 i had a lot of problems
of shifting the original game to where i am now. the casting and move ment works fine. the world drawing works good too
the only i isseu i have is whit the combat phase. i just dont understand that if you edit your code somewhere else
wich has noting to do whit a nother phase. like the combat phase it still cuases errors in that section
my phases are split by a case select. so case 0 is casting 1 movement 2 combat. but if i change to much code in 0 or 1 combat acts up

edit i see the ' command rems the rest too in my blitzmax the ' command only rems one line of text.
i dont know wy here after ' everything gets blocked out but at my blitzmax its a quick rem to skip one line of text



Midimaster

#6
I have to ask again... is this the whole code? In your new post it again starts with a line "CASE 2" ...

But a CASE command needs a SELECT command. Where is it???

Have you been able to switch to DEBUG mode?

Can you send the whole code? If you dont want to make it public send it to my email (see personal message).


There is definitely no "single line REM " in BlitzMax !!! BlitzMax always needs a END REM
...back from Egypt

Gijsdemik

Hey All!,

I am sorry for my late respons i do not have a lot of time to actuly work ion my game.
any how i found the piece of code that made the bug.

apperntly the new combat loop gave the bugs. there was still no refrance to any array to be rewritten.
but afther changeing it to the orginal combat code everything was fine.

I still wonder wy blitzmax would mess whit sections of codes that has nothing to do wit each ohter. like the combat is just one big loop. so chages there should not change my movement code or wat ever., also i started using the debug seems like a have lot of work to do to make the code clean.




Midimaster

BlitzMax runs perfect and  I doubt that you will find a bug/issue. In 99.99% of all strange behaviors it is a typo or a code bug of yourself.

So if you have the impression that BlitzMax mess with sections of code, the reason can be, that the sections are not independent as you think, but all together a big spaghetti code.

 I repeat again the offer to have a look on the complete code and advise (or supervise) your code style.

Urgent advise: 

Encapsulate single tasks into functions and use function calls when you do tasks multiple times.

Are you willing to give your code a readable structure?
...back from Egypt