Attacking City Walls

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!
Post Reply
VulcanScout
Posts: 6
Joined: Tue Nov 19, 2019 7:50 am

Attacking City Walls

Post by VulcanScout »

Hi,
Today morning it occured to me. For long it was a military tactic to undermine city walls and make them collapse. By digging a cavity under the city walls and either blowing up a large quantity of explosives; or earlier start a fire and set the mine prop on fire.
See also: https://en.wikipedia.org/wiki/Tunnel_warfare

Proposed unit flag:

Code: Select all

_("WallAttacker"), _("Can do a surgical strike attack against city walls")
Proposed unit:
units. Ruleset

Code: Select all

[unit_miners]
name          = _("Miners")
class         = "Land"
tech_req      = "Construction"
obsolete_by   = "Flight"
graphic       = "u.miner"
graphic_alt   = "u.engineer"
sound_move    = "m_warriors"
sound_move_alt = "m_generic"
sound_fight   = "f_warriors"
sound_fight_alt = "f_generic"
build_cost    = 20
pop_cost      = 0
attack        = 1
defense       = 1
hitpoints     = 6
firepower     = 1
move_rate     = 1
vision_radius_sq = 1
transport_cap = 0
fuel          = 0
uk_happy      = 0
uk_shield     = 1
uk_food       = 1
uk_gold       = 0
flags          = "WallAttacker", "BarbarianTech"
helptext      = _("\
Miners, or Sappers, are Combat Engineers who dig tunnels under\
 City Walls in order to breach through them.\
"), _("\
Miners are a cheap unit. Because they can be recruited from the city\
 population which has experience in mining. But they cost one food\
 per turn.
"), _("\
Miners are weak in offense and defense. They need an escort to be effective.
")
Miners become obsolete after the invention of flight. Because flight makes city walls obsolete too – at least in my ruleset.

Proposed Action:

Code: Select all

; /* TRANS: Destroy City Walls (33% chance of success). */
ui_name_surgical_strike_citywalls = _("Destroy City Walls")
That is the easy part, my question now is:
How can I write an action enabler for a surgical strike on city walls?

For game.ruleset

Code: Select all

[actionenabler_destroy_city_walls]
action = "User Action 2"
actor_reqs    = {
  "type",         "name",          "range", "present"
  "UnitFlag",     "WallAttacker",  "Local", TRUE
  "DiplRel",      "War",           "Local", TRUE
  "UnitState",    "OnLivableTile", "Local"  TRUE
  "MinMoveFrags", "1",             "Local"  TRUE
  "UnitState",    "Transported",   "Local", FALSE
}
target_reqs  = {
  "type",         "name",          "range",  "present"
  "Building",     "City Walls",    "City",   TRUE
}
For effects.ruleset

Code: Select all

[effect_action_success_move_cost_miner]
type    = "Action_Success_Actor_Move_Cost"
value   = 65535
reqs    = {
  "type", "name", "range", "present"
  "Action", "User Action 2", "Local", TRUE
}

[effect_destroywalls_half_chance]
type  = "Action_Odds_Pct"
value = -67
reqs  = {
  "type", "name", "range", "present"
  "Action", "User Action 2", "Local", TRUE
}
I only want to target the City Walls with the unit, nothing else.
am I'm doing it right?

\\//_ Live long and prosper
cazfi
Elite
Posts: 3150
Joined: Tue Jan 29, 2013 6:54 pm

Re: Attacking City Walls

Post by cazfi »

Not sure if it will work (I'm currently implementing some related missing parts for the sake of the granularity ruleset), but you need at least following changes.
VulcanScout wrote: Thu Apr 25, 2024 2:35 pm

Code: Select all

action = "User Action 2"
I think you wanted to use "Surgical Strike Building" action (at least that's what you were setting ui_name for), and not an user action you would implement in lua.
VulcanScout wrote: Thu Apr 25, 2024 2:35 pm

Code: Select all

"type",         "name",          "range",  "present"
  "Building",     "City Walls",    "City",   TRUE
}
Range should be "Local" to be able to target only the City Walls themselves, and not any building in a city with walls.
VulcanScout
Posts: 6
Joined: Tue Nov 19, 2019 7:50 am

Re: Attacking City Walls

Post by VulcanScout »

Hello,

You could say, this is the final version. If anyone has ideas, I‘ll listen.
Here‘s the result:

Screenshot from Messages:
miners_log.png
miners_log.png (20.57 KiB) Viewed 1166 times
Alt-Text:

Code: Select all

(T1 - 04:57:27) You have made contact with the Japanese, ruled by Jimmu.
(T1 - 04:57:58) Meeting with Jimmu canceled.
(T1 - 04:58:14) Your Miners was unable to do Surgical Strike Building.
(T1 - 04:58:14) Your Miners lost 1/9 MP for attempting an illegal action.
Your Miners failed to do Surgical Strike Building in Kyoto.
Your Miners destroyed the City Walls in Kyoto.
The illegal action was trying to force the city walls to collapse without the knowledge of construction.
Fixed. Hey, I ain‘t perfect. 🤷‍♂️

Code: Select all

;------------------------------------------------------------------------
; Surgical Strike City Walls units.ruleset
;------------------------------------------------------------------------

flags = {
  "name", "helptxt"
  _("WallAttacker"), _("Can do a surgical strike attack against city walls")
}

[unit_miners]
name          = _("Miners")
class         = "Land"
tech_req      = "Construction"
obsolete_by   = "None"
graphic       = "u.miners"
graphic_alt   = "u.engineer"
sound_move    = "m_warriors"
sound_move_alt = "m_generic"
sound_fight   = "f_warriors"
sound_fight_alt = "f_generic"
build_cost    = 20
pop_cost      = 0
attack        = 1
defense       = 1
hitpoints     = 6
firepower     = 1
move_rate     = 1
vision_radius_sq = 1
transport_cap = 0
fuel          = 0
uk_happy      = 0
uk_shield     = 1
uk_food       = 1
uk_gold       = 0
flags         = "Cant_Fortify","WallAttacker"
roles         = "BarbarianTech"
helptext      = _("\
Miners, or Sappers, are Combat Engineers who dig tunnels under\
 City Walls in order to cause them to collapse.\
"), _("\
Miners are a cheap unit. Because they can be recruited from the city\
 population which has experience in mining. But they cost 1 food\
 per turn.
"), _("\
Miners are weak in offense and defense. They need an escort to be effective.
")
Unit sprite, taken from an image called:
Ancient and Medieval Styled Units
- Compiled By Harlan Thompson
u_miners.png
u_miners.png (1.39 KiB) Viewed 1166 times

Code: Select all

;------------------------------------------------------------------------
; Surgical Strike City Walls game.ruleset
;------------------------------------------------------------------------
; /* TRANS: Destroy City Walls (33% chance of success). */
ui_name_surgical_strike_citywalls = _("Destroy City Walls")

[actionenabler_destroy_city_walls]
action = "Surgical Strike Building"
actor_reqs    = {
  "type",         "name",          "range", "present"
  "UnitFlag",     "WallAttacker",  "Local", TRUE
  "DiplRel",      "War",           "Local", TRUE
  "UnitState",    "OnLivableTile", "Local", TRUE
  "MinMoveFrags", "1",             "Local", TRUE
  "UnitState",    "Transported",   "Local", FALSE
}
target_reqs  = {
  "type",         "name",          "range",  "present"
  "Building",     "City Walls",    "Local",   TRUE
}

Code: Select all

;------------------------------------------------------------------------
; Surgical Strike City Walls effects.ruleset
;------------------------------------------------------------------------
[effect_action_success_move_cost_miner]
type    = "Action_Success_Actor_Move_Cost"
value   = 65535
reqs    = {
  "type", "name", "range", "present"
  "Action", "Surgical Strike Building", "Local", TRUE
}

[effect_destroywalls_chance]
type  = "Action_Odds_Pct"
value = -67
reqs  = {
  "type", "name", "range", "present"
  "Action", "Surgical Strike Building", "Local", TRUE
}
So, if anyone wants to copy it, feel free to do it.

\\//_
Post Reply