Author Topic: [WB][Script] Weapon breaking trigger  (Read 4384 times)

0 Members and 1 Guest are viewing this topic.

Gaunt

  • Knight at Arms
  • *
    • View Profile
  • Faction: Khergit
  • NW
[WB][Script] Weapon breaking trigger
« on: July 31, 2010, 10:30:22 PM »
Hello folks, just thought I'd share a trigger that made for in-battle weapon breaking.


Whenever you hit an enemy there is a chance that your weapon will be destroyed/lost (Simulates weapon wear and weapons being stuck in enemy or lances shattering completely.)

Different break rates.
All weapons are a little more likely to be lost on horseback.
Polearms are lost MUCH more when on horseback.
Polearms on foot are lost a little more than other weapons.
Two handed weapons are lost a little more than one handed weapons.

When you lose your weapon it is gone forever, remember that you can get spare weapons from your box when they break.





Code:

(click to show/hide)

Numbers can be changed based on your preference, remember not to use decimals! That is why I multiply by 101 ect and then divide by 100.


common_weapon_break will need to be added to each mission template you want it in, WARNING:It does not work as-is on multiplayer, if you want to figure that out yourself go ahead.


Any questions, please ask.




Somebody

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: Weapon breaking trigger [Open Source]
« Reply #1 on: July 31, 2010, 10:48:39 PM »
It probably makes more sense to have polearms break more often when blocking.
Also, it's probably better practice to simply assign an upper limit per weapon type (rather than the repeated val_mul/div), and then store the random number afterwards.

Gaunt

  • Knight at Arms
  • *
    • View Profile
  • Faction: Khergit
  • NW
Re: Weapon breaking trigger [Open Source]
« Reply #2 on: July 31, 2010, 11:05:11 PM »
1. Sorry, the game doesn't tell you when you block a blow.

2. I did it this way because it allows the horse multiplier and weapon multipliers to all count. Rather than having 6 different try_begins one for each combination of horse and weapon or not.



bjorne.

  • Sergeant Knight
  • *
  • I'm a nerd... deal with it..
    • View Profile
    • Age of Blackpowder - Realm of Revolution
  • Faction: Swadian
Re: Weapon breaking trigger [Open Source]
« Reply #3 on: August 01, 2010, 05:19:41 PM »
Clever!

Kolba

  • Guest
Re: Weapon breaking trigger [Open Source]
« Reply #4 on: August 01, 2010, 05:24:07 PM »
Great! Will it also work in 1.011?
« Last Edit: August 01, 2010, 05:50:41 PM by Kolba »

Weren

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Khergit
  • MP nick: irc://Weren, Nord_Weren
Re: Weapon breaking trigger [Open Source]
« Reply #5 on: August 01, 2010, 05:35:59 PM »
Brilliant!
Quote
[20:58] <@Faraderp> this conversation is stupid
[20:58] <@Faraderp> I end
[20:58] <+Ursca> No, you are the stupid one
[20:58] <@Faraderp> ;_;
[20:58] <@Faraderp> No Im totally not
[20:59] <+Ursca> You sound defensive
[20:59] <@Faraderp> no u
[21:00] <+Ursca> Goddamn I have been utterly rebuked
[21:00] <+Ursca> I surrender
[21:00] <@Faraderp> Yes, good for you
[21:02] <@Faraderp> My discussion skills nearly crushed your poor little mind

McBeverage

  • Not a number, a free man!
  • Grandmaster Knight
  • *
  • On the edge - spirit begins to break.
    • View Profile
  • Faction: Neutral
  • MP nick: Botchbrood_McBeverage
  • M&BWB
Re: Weapon breaking trigger [Open Source]
« Reply #6 on: August 01, 2010, 06:38:55 PM »
Great stuff man! 
can i  have friendly hand shack
A friendly hand shack?  That sounds like some shady masturbation establishment.
How about bane for the insult of user?

iggorbb

  • Master Knight
  • *
  • ...meh...
    • View Profile
  • Faction: Vaegir
  • MP nick: terorminator
Re: Weapon breaking trigger [Open Source]
« Reply #7 on: August 01, 2010, 06:52:45 PM »
1.011?
Btw, nice done.
Бој не бије свијетло оружје, већ бој бије срце у јунака.

bb_osp

Cruger

  • Guest
Re: Weapon breaking trigger [Open Source]
« Reply #8 on: August 01, 2010, 08:00:21 PM »
Awesome job, I hope you don't mind me posting my own personal modification, this makes the weapons breakable for the AI too, however only if they have 2 or more melee weapons (same goes for player btw, but that can easily be removed I think). That way it doesn't end up with a bunch of AI fistfighting.

I bet that there is a more effective way to do than the way I did, but I'm new to the mission_template world.

(click to show/hide)

(click to show/hide)

I don't trigger the sound every time a weapon is broke because the sound is just as loud no matter how far away the weapon that break is, and that is quite annoying. So you can only hear it when it happens to the player.

I have tested it, and it works.

FrisianDude

  • Coitus non Awesome
  • Grandmaster Knight
  • *
  • Zis is Tshörman tärritorie!
    • View Profile
  • Faction: Neutral
  • MP nick: OLL_SirAndelot/Liudulf Ward
  • M&BWB
Re: Weapon breaking trigger [Open Source]
« Reply #9 on: August 01, 2010, 08:24:19 PM »
Very nice, does it work in Multiplayer?
Nords ruled by King Ragnar, Khergits ruled by Sanjar Khan, Rhodoks ruled by King Graveth, Swadians ruled by King Harlaus, Vaegirs ruled by King Yaroglek. All those peoples live, fight, and die in the continent of Calradia. The Nords and Rhodoks field solely infantry and archers, the Swadians and Vaegirs have infantry, archers and cavalry and the Khergit field almost exclusively cavalry. No such things as "infarty" or "calvary" exist. Play Vikingr!

Somebody

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: Weapon breaking trigger [Open Source]
« Reply #10 on: August 01, 2010, 08:30:34 PM »
If you're going to try for all agents, then you'd probably want to make sure the agent isn't dead (agent_is_alive), or a horse (agent_is_human) or something. And you can use agent_play_sound for the bots if you really wanted to.

As to improvements, instead of going through all the items, for every agent, you want to go through the agent's troop's inventory. Use agent_get_troop_id, troop_get_inventory_capacity, try_for_range, troop_get_inventory_slot, item_get_type, agent_has_item_equipped, etc. And inside the loop itself you want to break out as soon as you've got 2 suitable items (set the upper limit in the try_for_range to 0). Finally, instead of comparing the itps to your item type, you'll want to use (is_between, ":weapontype2", itp_one_handed_wpn, itp_type_polearm).

Also, this won't work on 1.011 since agent_get_attack_action is a Warband addition.

Also, this won't work in multiplayer at all since multiplayer doesn't actually use troop inventories, etc, so you'd have to remove it in a different way.

Cruger

  • Guest
Re: Weapon breaking trigger [Open Source]
« Reply #11 on: August 01, 2010, 08:50:54 PM »
If you're going to try for all agents, then you'd probably want to make sure the agent isn't dead (agent_is_alive), or a horse (agent_is_human) or something. And you can use agent_play_sound for the bots if you really wanted to.

Don't you automatically get rid of horses and dead agents at this part?

(try_for_agents, ":player_agent"),
      (agent_get_attack_action, ":playeraction", ":player_agent"), #returned values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7
        (try_begin),
             (eq,":playeraction",3),

As to improvements, instead of going through all the items, for every agent, you want to go through the agent's troop's inventory. Use agent_get_troop_id, troop_get_inventory_capacity, try_for_range, troop_get_inventory_slot, item_get_type, agent_has_item_equipped, etc. And inside the loop itself you want to break out as soon as you've got 2 suitable items (set the upper limit in the try_for_range to 0). Finally, instead of comparing the itps to your item type, you'll want to use (is_between, ":weapontype2", itp_one_handed_wpn, itp_type_polearm).

Thanks alot. But it should be  (is_between, ":weapontype2", itp_one_handed_wpn, itp_type_arrows), or it wont count polearms. Anyways, the other stuff is a tad to advanced for me. Other than adding naval battles this is pretty much the first time I play around in the mission_templates.

Somebody

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: Weapon breaking trigger [Open Source]
« Reply #12 on: August 01, 2010, 09:08:43 PM »
Yes, but it's a waste of cpu cycles using that operation, when checking whether or not the agent can actually have an attack action is faster. And I was typing from memory, hence the list of operations without parameters.

Gaunt

  • Knight at Arms
  • *
    • View Profile
  • Faction: Khergit
  • NW
Re: Weapon breaking trigger [Open Source]
« Reply #13 on: August 02, 2010, 01:09:23 AM »
@Kolba and iggorbb

I assume so, I haven't tried it though.

@Cruger feel free to change it and post your changes, it's all for the good of the modding community.


Doesn't work in multiplayer though it could probably be changed to work with multiplayer.

sourblood

  • Sergeant
  • *
    • View Profile
  • Faction: Neutral
Re: Weapon breaking trigger [Open Source]
« Reply #14 on: August 14, 2010, 10:59:33 PM »
So... this goes into what file, module_mission_templates.py or module_triggers.py? Or another?