New weapon - Auto Defense! And AI bugfixes

This commit is contained in:
Pecusx
2022-11-09 10:32:50 +01:00
parent a7493e1dcb
commit 3f74494bed
9 changed files with 74 additions and 21 deletions
+21 -14
View File
@@ -44,6 +44,7 @@ loop
; common values used in AI routines
; address of weapons table (for future use)
WepTableToTemp
lda TanksWeaponsTableL,x
sta temp
lda TanksWeaponsTableH,x
@@ -210,6 +211,19 @@ AngleTable ; 16 bytes ;ba w $348b L$3350
.endp
;----------------------------------------------
.proc UseBatteryOrFlag
jsr UseBattery ; as subroutine for reuse in AutoDefense
; if very low energy and no battery then use White Flag
lda Energy,x
cmp #5
bcs EnoughEnergy
; lower than 5 units - white flag
lda #ind_White_Flag_____
sta ActiveDefenceWeapon,x
EnoughEnergy
rts
.endp
;
.proc UseBattery
; if low energy ten use battery
lda Energy,x
cmp #30
@@ -219,20 +233,13 @@ AngleTable ; 16 bytes ;ba w $348b L$3350
lda (temp),y ; has address of TanksWeaponsTable
beq NoBatteries
; we have batteries - use one
clc
sec
sbc #1
sta (temp),y
lda #99
sta Energy,x
NoBatteries
; if very low energy and no battery then use White Flag
lda Energy,x
cmp #5
bcs EnoughEnergy
; lower than 5 units - white flag
lda #ind_White_Flag_____
sta ActiveDefenceWeapon,x
EnoughEnergy
NoBatteries
rts
.endp
;----------------------------------------------
@@ -245,7 +252,7 @@ EnoughEnergy
; first check check if any is in use
lda ActiveDefenceWeapon,x
bne DefensiveInUse
ldy #last_defensive_____+1 ;the last defensive weapon
ldy #last_real_defensive+1 ;the last defensive weapon
@
dey
cpy #ind_Battery________ ;first defensive weapon (White Flag and Battery - never use)
@@ -253,7 +260,7 @@ EnoughEnergy
lda (temp),y ; has address of TanksWeaponsTable
beq @-
; decrease in inventory
clc
sec
sbc #1
sta (temp),y ; has address of TanksWeaponsTable
; activate defensive weapon
@@ -280,7 +287,7 @@ DefensiveInUse
; first check check if any is in use
lda ActiveDefenceWeapon,x
bne DefensiveInUse
ldy #last_defensive_____+1 ;the last defensive weapon
ldy #last_real_defensive+1 ;the last defensive weapon
@
dey
cpy #ind_Battery________ ;first defensive weapon (White Flag and Battery - never use)
@@ -288,7 +295,7 @@ DefensiveInUse
lda (temp),y ; has address of TanksWeaponsTable
beq @-
; decrease in inventory
clc
sec
sbc #1
sta (temp),y ; has address of TanksWeaponsTable
; activate defensive weapon
@@ -575,7 +582,7 @@ skipThisPlayer
asl
tay
; force correction - lower tank Y position - higher possible force
clc
sec
lda #screenheight
sbc Ytankstable,x
sta temp2
+8 -2
View File
@@ -276,6 +276,7 @@ WeaponPriceH ; weapons prices (tables with prices of weapons)
.by >price_Nuclear_Winter_
.by >price_Lazy_Boy_______
.by >price_Lazy_Darwin____
.by >price_Auto_Defense___
WeaponPriceL
.by <price_Baby_Missile___
.by <price_Missile________
@@ -323,6 +324,7 @@ WeaponPriceL
.by <price_Nuclear_Winter_
.by <price_Lazy_Boy_______
.by <price_Lazy_Darwin____
.by <price_Auto_Defense___
;-------------------------------------------------
; how many units (bulletd) of a given weapon we get for a given price
@@ -377,6 +379,7 @@ WeaponUnits
.by 1 ;Nuclear_Winter_;_43
.by 2 ;Lazy_Boy_______;_44
.by 2 ;Lazy_Darwin____;_45
.by 2 ;Auto_Defense___;_46
PurchaseMeTable ;weapons good to be purchased by the robot
;the comment is an index in the tables
@@ -396,7 +399,7 @@ PurchaseMeTable ;weapons good to be purchased by the robot
; "Strong Parachute","Mag Deflector ","Shield ","Heavy Shield "
.by %01011111
; "Force Shield ","Bouncy Castle ","Long Barrel ","Nuclear Winter "
; "Lazy Boy ","Lazy Darwin "
; "Lazy Boy ","Lazy Darwin ","Auto Defense "
.by %11000000
PurchaseMeTable2 ;weapons good to be purchased by the robot (Cyborg)
@@ -417,7 +420,7 @@ PurchaseMeTable2 ;weapons good to be purchased by the robot (Cyborg)
; "Strong Parachute","Mag Deflector ","Shield ","Heavy Shield "
.by %01001101
; "Force Shield ","Bouncy Castle ","Long Barrel ","Nuclear Winter "
; "Lazy Boy ","Lazy Darwin "
; "Lazy Boy ","Lazy Darwin ","Auto Defense "
.by %11000000
;-------------------------------------------------
@@ -469,6 +472,7 @@ WeaponSymbols
.by $7d ;ind_Nuclear_Winter_ ;_43
.by $02 ;ind_Lazy_Boy_______ ;_44
.by $03 ;ind_Lazy_Darwin____ ;_45
.by $5e ;ind_Auto_Defense___ ;_46
; Names of weapons (16 chars long)
NamesOfWeapons ;the comment is an index in the tables
@@ -519,6 +523,7 @@ NamesOfWeapons ;the comment is an index in the tables
dta d"Nuclear Winter " ; 43
dta d"Lazy Boy " ; 44
dta d"Lazy Darwin " ; 45
dta d"Auto Defense " ; 46
DefensiveEnergy = *-(last_offensive_____ - first_offensive____ +1) ; to fake the table for ALL weapons
.by 00 ; White Flag
@@ -535,6 +540,7 @@ DefensiveEnergy = *-(last_offensive_____ - first_offensive____ +1) ; to fake th
.by 00 ; Nuclear Winter
.by 00 ; Lazy Boy
.by 00 ; Lazy Darwin
.by 00 ; Auto Defense
weaponsOfDeath ; weapons used in tank death animations
dta 1,2,3,7,17,18,19,20,21,22,23,24,25,26,27
weaponsOfDeathEnd
+4 -1
View File
@@ -86,6 +86,7 @@ price_Long_Barrel____ = 2100 ;_42
price_Nuclear_Winter_ = 1000 ;_43
price_Lazy_Boy_______ = 500 ;_44
price_Lazy_Darwin____ = 500 ;_45
price_Auto_Defense___ = 150 ;_46
;Weapon indexes (numbers)
ind_Baby_Missile___ = 0
first_offensive____ = ind_Baby_Missile___
@@ -136,7 +137,9 @@ ind_Long_Barrel____ = 42
ind_Nuclear_Winter_ = 43
ind_Lazy_Boy_______ = 44
ind_Lazy_Darwin____ = 45
last_defensive_____ = ind_Lazy_Darwin____
ind_Auto_Defense___ = 46
last_defensive_____ = ind_Auto_Defense___
last_real_defensive = ind_Bouncy_Castle__
number_of_offensives = last_offensive_____ - first_offensive____+1
number_of_defensives = (last_defensive_____ - first_defensive____+1)
;--------------------------------
+18 -2
View File
@@ -324,6 +324,7 @@ MainGameLoop
jsr SetWallsType
; first set default barrel lengths (fix for Long Schlong activation :) )
; we must do it before purchase/activate
; and set Auto Defense to off
jsr SetStandardBarrels
jsr CallPurchaseForEveryTank
@@ -612,6 +613,19 @@ DoNotFinishTheRound
jmp Seppuku
@
; Auto Defense - activates defensives
ldx NumberOfPlayers
dex
CheckNextTankAD
lda Energy,x
beq @+
lda AutoDefenseFlag,x
beq @+
; run auto defense for tank in X
jsr AutoDefense
@ dex
bpl CheckNextTankAD
;
ldx TankSequencePointer
lda TankSequence,x
sta TankNr
@@ -1129,8 +1143,10 @@ MakeTanksVisible
;--------------------------------------------------
.proc SetStandardBarrels
ldx #maxPlayers-1
lda #StandardBarrel ; standard barrel length
@ sta BarrelLength,x
@ lda #StandardBarrel ; standard barrel length
sta BarrelLength,x
lda #$00 ; deactivate Auto Defense
sta AutoDefenseFlag,x
dex
bpl @-
rts
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+9
View File
@@ -848,6 +848,13 @@ invSelectDef
ply
jmp DecreaseDefensive ; bypass activation
NotBattery
cmp #ind_Auto_Defense___
bne NoAutoDefense
; Auto Defense - do it like battery
mva #sfx_battery sfx_effect
mva #$A1 AutoDefenseFlag,x ; this is "A" in inverse - for status line :)
jmp DecreaseDefensive ; bypass activation
NoAutoDefense
cmp #ind_Lazy_Boy_______
bne NoLazyBoy
; Lazy Boy - do it like battery
@@ -2343,6 +2350,8 @@ EndOfCredits
;---------------------
;displaying name of the defence weapon (if active)
;---------------------
lda AutoDefenseFlag,x ; Auto Defense symbol (space or "A" in inverse)
sta statusBuffer+80+21
lda #$08 ; (
sta statusBuffer+80+22
lda #$09 ; )
+2
View File
@@ -127,6 +127,8 @@ ActiveWeapon ;number of the selected weapon
.DS MaxPlayers
ActiveDefenceWeapon ;number of the activated defence weapon - 0
.DS MaxPlayers
AutoDefenseFlag ; 0 - not activated, >$7f - activated
.DS MaxPlayers
WeaponDepleted .DS 1 ; if 0 deactivate the weapon and switch to Baby Missile
;----------------------------------------------------
+11 -1
View File
@@ -2418,7 +2418,17 @@ InverseScreenByte
sta (temp),y
rts
.endp
; -------------------------------------------------
.proc AutoDefense
; -------------------------------------------------
; This routine is run from inside of the main loop
; X - index of tank
; -------------------------------------------------
jsr PrepareAIShoot.WepTableToTemp
jsr UseBattery
jsr TosserDefensives
rts
.endp
; -------------------------------------------------
.proc TankFlying
; -------------------------------------------------