[WB] Warband Script Enhancer v3.2.0 (21/07/2013)

Users who are viewing this thread

Status
Not open for further replies.
Just started work with WSE and it's awesome.

I was wandering if it's possible to add extra param to script game_get_upgrade_cost, just to know for which upgrade it's called? I tried doing it different ways but there is always some problems. The interface support different upgrade cost, but game_get_upgrade_cost single param makes it very problematic.
 
Hello, thanks for the release...

I'm a bit embarrassed to keep on asking for features.
I can only ease that by offering my help do to so.
In addition, keep in mind that I only ask for features that would be actually used, and which cannot be substituted by work-arounds (to the best of my knowledge).

Also, I'm personally very much interested in M&B enhancing (not WB), so I hope that side project is kept alive and at par with this one. I'm not very fluent in WB modding so apologies if what I say refers to M&B only.


Enough chat! :smile: So, potential new features:

(1)
Code:
([b]agent_remove_horse[/b], agent_id),
// stores agent horse in reg0
Code:
([b]agent_set_horse[/b], agent_id, horse_id),

to add or remove an horse piloted by an agent. It would be responsibility of the mod to give proper animations/positions to rider and horse so to avoid glitches. I think I'm not the only one who was puzzled by the lack of these. I wonder if that's possible.

(2)
Code:
( [b]agent_damage_shield[/b], agent_id, damage_amount ),
which can occasionally shatter the shield, if it reaches 0.


(3)
Code:
([b] icon_activate_animation[/b], icon_id, frame_time_start, frame_time_end ),
    // sets an animated icon to loop from frame at time_time_start to a frame at frame_time_end (included).

Note: currently, map animations roll from 100 to 140 whenever they move, regardless of how many frames they have, and are fixed to frame at time 0 when they stay still.

I think that default should be changed: not "from 100 to 140" but "from 100 to whatever the maximal time is in the brf file".
And I would give the possibility to override that by the command above.
It is ok that the time rolls at a fixed pace (you would just change the timings in the brf-file to set the speed).

Setting time_start = time_end would naturally mean to stop the animation at a given frame. If the frame is not found, frame 0 should be used.



Also, I would very much like to see a few shortcoming of the system patched:

(4) currently meshes of boots are not customizable per skin (e.g. their feminine frame, if there, is just ignored). It would be cool
if it behaved just like armors.

(5) currently skins specify rigid calves (you specify the left-calf mesh, and the right one is determined automatically). It would be better if they could specify a rigged pair of calves instead, just like boot objects. Better animations that way, and more customization possible.
 
mtarini said:
(1)
Code:
([b]agent_remove_horse[/b], agent_id),
// stores agent horse in reg0
Code:
([b]agent_set_horse[/b], agent_id, horse_id),

to add or remove an horse piloted by an agent. It would be responsibility of the mod to give proper animations/positions to rider and horse so to avoid glitches. I think I'm not the only one who was puzzled by the lack of these. I wonder if that's possible.
On the same topic, forcing an agent to mount or dismount would be swell. ...but I think you've mentioned before that this may not be possible.

Using (remove_agent) on the horse agent might accomplish what you are trying with (agent_remove_horse), mtarini...though it leaves a dead horse then on the ground, so it would need to be coupled with a set_position or something else to get rid of that dead horse.
mtarini said:
(2)
Code:
( [b]agent_damage_shield[/b], agent_id, damage_amount ),
which can occasionally shatter the shield, if it reaches 0.
A combination of these should accomplish this, I would think:
Code:
agent_get_item_slot_hit_points = 3311 #(agent_get_item_slot_hit_points, <destination>, <agent_no>, <item_slot_no>), #Stores <agent_no>'s <item_slot_no> shield hitpoints into <destination>
agent_set_item_slot_hit_points = 3312 #(agent_set_item_slot_hit_points, <agent_no>, <item_slot_no>, <value>), #Sets <agent_no>'s <item_slot_no> shield hitpoints to <value>
agent_get_wielded_item_slot_no = 3313 #(agent_get_wielded_item_slot_no, <destination>, <agent_no>, [<hand_no>]), #Stores <agent_no>'s wielded item slot for [<hand_no>] into <destination>

something like
Code:
("agent_damage_shield", [
  (store_script_param, ":agent_id", 1),
  (store_script_param, ":damage", 2),

  (try_begin),
      (agent_get_wielded_item, ":item", ":agent_id", 1),
      (gt, ":item", 0),
      (item_get_type, ":type", ":item"),
      (eq, ":type", itp_type_shield), #are these two necessary? is anything but a shield wielded in the left hand?
      (agent_get_wielded_item_slot_no, ":ek_slot", ":agent_id", 1), #everything above this might not even be necessary if this returns -1 if there is nothing wielded in the left hand and the left hand implies shield
      (agent_get_item_slot_hit_points, ":hp", ":agent_id", ":ek_slot"),
      (val_sub, ":hp", ":damage"),
      (val_max, ":hp", 0), ##not sure if necessary
      (agent_set_item_slot_hit_points, ":agent_id", ":ek_slot", ":hp"),
  (try_end),
]),
 
Caba`drin said:
mtarini said:
(1)
Code:
([b]agent_remove_horse[/b], agent_id),
// stores agent horse in reg0
Code:
([b]agent_set_horse[/b], agent_id, horse_id),

to add or remove an horse piloted by an agent. It would be responsibility of the mod to give proper animations/positions to rider and horse so to avoid glitches. I think I'm not the only one who was puzzled by the lack of these. I wonder if that's possible.
On the same topic, forcing an agent to mount or dismount would be swell. ...but I think you've mentioned before that this may not be possible.

Using (remove_agent) on the horse agent might accomplish what you are trying with (agent_remove_horse), mtarini...though it leaves a dead horse then on the ground, so it would need to be coupled with a set_position or something else to get rid of that dead horse.

There is a function
Code:
(agent_start_running_away, ":horse")
which when used on a mounted horse makes the agent 'fall off' instantly and the horse will run away. It's what I use for my dehorsing script. Maybe that helps?
 
Barabas said:
There is a function
Code:
(agent_start_running_away, ":horse")
which when used on a mounted horse makes the agent 'fall off' instantly
Good to know, thanks... that would be great (assuming the horse can be recovered immediately later), but unfortunately M&B lacks that  command.

I knew I should have posted this in the pre-WB/M&B. Script Enhancer thread.


[quote author=Caba`drin]
...
[/quote]great finds, thanks!
But, would that actually break the shield? mmm... worth a try.

Again, i would really like this project to be unified with the M&B counterpart... either that, or I postpone everything until the day when and if we port TLD to warband.


Anyway, not that I can use this until the first two of the following three are implemented:

(I quote myself on these, because I've posted them in the other M&B only thread...)

Code:
([b]agent_get_animation[/b], dest, agent_id),
                # returns id of current animation of an agent
Code:
([b]agent_get_animation_progress[/b], dest, agent_id),
  # just like the "set" command

...and...

Code:
([b]agent_set_rotation[/b], agent_id, pos_id),
  # sets rotations. Current agent_set_position doesn't (at least, in M&B)

These three are on top of my list.



And I don't stop here! I wonder if this is possible at all:

Code:
([b]agent_ai_threaten[/b], agent_id, pos_id , mode),
  #modes = (0:eek:verhead 1:left swing 2:right swing 3:thrust 4:shield only)

...which  would threaten a NPC agent, so that he will want to parry or block (but will do so, or not, according to normal AI), just like if threatened by an attack of the given kind coming from the given position-direction. Mode 4 is like for arrows.

(edit: maybe it is easier to implement that as some sort of
"(set_threat, pos_id, mode, duration, team_no)"
which sets an invisible threat for all AI agent opposing given team, like if an attack of the given mode was issued from that position and orientation.

Now I stop.
 
Barabas said:
There is a function
Code:
(agent_start_running_away, ":horse")
which when used on a mounted horse makes the agent 'fall off' instantly and the horse will run away. It's what I use for my dehorsing script. Maybe that helps?
Great to know. Thanks, Barabas.

mtarini said:
Code:
([b]agent_get_animation[/b], dest, agent_id),
                # returns id of current animation of an agent
This is native to Warband

mtarini said:
Code:
([b]agent_get_animation_progress[/b], dest, agent_id),
  # just like the "set" command
This is already in WSE.

mtarini said:
Code:
([b]agent_set_rotation[/b], agent_id, pos_id),
  # sets rotations. Current agent_set_position doesn't (at least, in M&B)
agent_set_position effectively uses rotation in Warband iff there is a change in actual position. I don't believe it will work if the X,Y,Z is approximately the same, but I'll need to retest...I know it works if you are moving an agent any distance. (I cannot speak to M&B)

mtarini said:
Code:
([b]agent_ai_threaten[/b], agent_id, pos_id , mode),
  #modes = (0:eek:verhead 1:left swing 2:right swing 3:thrust 4:shield only)

...which  would threaten a NPC agent, so that he will want to parry or block (but will do so, or not, according to normal AI), just like if threatened by an attack of the given kind coming from the given position-direction. Mode 4 is like for arrows.

(edit: maybe it is easier to implement that as some sort of
"(set_threat, pos_id, mode, duration, team_no)"
which sets an invisible threat for all AI agent opposing given team, like if an attack of the given mode was issued from that position and orientation.
Native to Warband:
(agent_set_attack_action, <agent_id>, <value>, <value>), #value: 0 = thrust, 1 = slashright, 2 = slashleft, 3 = overswing - second value 0 = ready and release, 1 = ready and hold
"thrust" is equivalent to "shoot/throw".

or
(agent_set_defend_action, <agent_id>, <value>, <duration-in-1/1000-seconds>), #value_1: 0 = defend_down, 1 = defend_right, 2 = defend_left, 3 = defend_up

...but now that I look at it, that doesn't seem to be quite what you mean, does it?
 
Caba`drin said:
mtarini said:
Code:
([b]agent_set_rotation[/b], agent_id, pos_id),
  # sets rotations. Current agent_set_position doesn't (at least, in M&B)
agent_set_position effectively uses rotation in Warband iff there is a change in actual position. I don't believe it will work if the X,Y,Z is approximately the same, but I'll need to retest...I know it works if you are moving an agent any distance. (I cannot speak to M&B)
Just a quibble, agent_set_position does not properly set the rotation of players in MP Warband, as their mouse-look direction overrides it. I would love to see this force rotation on all accounts, as it makes teleporting agents cumbersome or unpolished depending how you do it.
 
Waldzios said:
I was wandering if it's possible to add extra param to script game_get_upgrade_cost, just to know for which upgrade it's called? I tried doing it different ways but there is always some problems. The interface support different upgrade cost, but game_get_upgrade_cost single param makes it very problematic.
Probably can't be done, I think the game just calls it once and then uses the value for both upgrades.
mtarini said:
Also, I'm personally very much interested in M&B enhancing (not WB), so I hope that side project is kept alive and at par with this one. I'm not very fluent in WB modding so apologies if what I say refers to M&B only.
I didn't even know that there was a Mount&Blade SE. :grin:
Nice to see that I'm not the only master of rglPool.
mtarini said:
Code:
([b]agent_remove_horse[/b], agent_id),
// stores agent horse in reg0
Code:
([b]agent_set_horse[/b], agent_id, horse_id),
Might be possible, but I need to investigate.
mtarini said:
Code:
( [b]agent_damage_shield[/b], agent_id, damage_amount ),
which can occasionally shatter the shield, if it reaches 0.
Unfortunately Caba`drin's solution won't break the shield, but it should be possible to add an operation that does.
mtarini said:
Code:
([b] icon_activate_animation[/b], icon_id, frame_time_start, frame_time_end ),
    // sets an animated icon to loop from frame at time_time_start to a frame at frame_time_end (included).

Note: currently, map animations roll from 100 to 140 whenever they move, regardless of how many frames they have, and are fixed to frame at time 0 when they stay still.

I think that default should be changed: not "from 100 to 140" but "from 100 to whatever the maximal time is in the brf file".
And I would give the possibility to override that by the command above.
It is ok that the time rolls at a fixed pace (you would just change the timings in the brf-file to set the speed).

Setting time_start = time_end would naturally mean to stop the animation at a given frame. If the frame is not found, frame 0 should be used.
The operation is way too much work for the time I have (requires patching stuff in the frame logic), but I might be able to do something for the 100-140 limitation (if it's a hardcoded range).
mtarini said:
(4) currently meshes of boots are not customizable per skin (e.g. their feminine frame, if there, is just ignored). It would be cool
if it behaved just like armors.
mtarini said:
(5) currently skins specify rigid calves (you specify the left-calf mesh, and the right one is determined automatically). It would be better if they could specify a rigged pair of calves instead, just like boot objects. Better animations that way, and more customization possible.
Both should be possible, I'll look into it.
mtarini said:
Code:
([b]agent_get_animation[/b], dest, agent_id),
                # returns id of current animation of an agent
Already in Warband.
mtarini said:
Code:
([b]agent_get_animation_progress[/b], dest, agent_id),
  # just like the "set" command
Already in WSE.
mtarini said:
Code:
([b]agent_set_rotation[/b], agent_id, pos_id),
  # sets rotations. Current agent_set_position doesn't (at least, in M&B)
Should be possible for AI agents and might be possible for the player (but I think it requires fiddling with the tactical window camera, or the agent will just rotate back to the look direction). For multiplayer it's trickier: it needs a custom network event that tells the player to change camera rotation.
mtarini said:
Code:
([b]agent_ai_threaten[/b], agent_id, pos_id , mode),
  #modes = (0:eek:verhead 1:left swing 2:right swing 3:thrust 4:shield only)

...which  would threaten a NPC agent, so that he will want to parry or block (but will do so, or not, according to normal AI), just like if threatened by an attack of the given kind coming from the given position-direction. Mode 4 is like for arrows.

(edit: maybe it is easier to implement that as some sort of
"(set_threat, pos_id, mode, duration, team_no)"
which sets an invisible threat for all AI agent opposing given team, like if an attack of the given mode was issued from that position and orientation.
I don't know AI well enough, but I fear it would require modifying the AI routines, and unfortunately I don't have time for that.
Specialist said:
Can I suggest that you bring back the WSE animation stuff that was existant back in the 1.134 days?
Way too much work for something that was extremely hacky. However, in "WSE2" (which won't be released anytime soon, because I have little time to work on it) there will be something like that, except even more customizable.
 
cmpxchg8b said:
Waldzios said:
I was wandering if it's possible to add extra param to script game_get_upgrade_cost, just to know for which upgrade it's called? I tried doing it different ways but there is always some problems. The interface support different upgrade cost, but game_get_upgrade_cost single param makes it very problematic.
Probably can't be done, I think the game just calls it once and then uses the value for both upgrades.
It's called few times:
Lav said:
When you select a troop in the party window, the game calls script_game_get_upgrade_cost once for each available upgrade path - that is, once or twice. You can check if the script is supposed to be called once or twice by checking that the troop has a second upgrade path available.

When the troop is upgraded, it looks like script_game_get_upgrade_cost is called once to get the cost of selected upgrade, and then twice to get all upgrade costs. No idea why. So for troops with 1 upgrade path, script is called 3 times during upgrade. For troops with 2 upgrade paths, the script is called 5 times.
Example that there are two values (at least for interface):
upgradec.jpg
There is Lav solution, OSP/Python Script Exchange, but there is no way for it to work in all situation (will not detect the upgrade if the upgraded troop is at the top of the tree).
 
Just a clarification, what I meant was:

Code:
([b]agent_detach_horse[/b], agent_id),
# stores detached agent horse in reg0
Code:
([b]agent_attach_horse[/b], agent_id, horse_id),
[/quote]

(I meaning that horse and rider already there). These would probably be better names.
Saying "set" and "remove" as I did above wasn't very clear probably.


Confirm: at least in M&B, the interval 100-140 for map animation is hard-coded. It should be at least 100-[time-of-last-frame] IMO.


I'm a bit undecided about what to do now.
On one hand, I would really like access to many of these commands, for TLD, which I learn are either in WSE or in plain-WB apparently. So I would like a lot these to be supported in M&B.
On the other, eventually TLD might go WB, and and that point any effort to enlarge the operation set in M&B would be kinda wasted.
 
(set_result_string,...) for script "wse_console_command_received" doesn't seem to work. I always get the default message, no matter what string is set.

edit: I realize that this is a very minor thing, but still... :wink: It would be enough if the default message wouldn't appear at all, since "display_message" seem to work fine here.
 
Status
Not open for further replies.
Back
Top Bottom