<< Back to Programming Forum   Search

Posts 1 - 20 of 36   1  2  Next >>   
Change result of attack/transfer: 8/30/2020 08:02:15


krinid 
Level 62
Report
How can I change the result of an attack/transfer?

In my case, I'm looking to make result.IsSuccessful change from false to true to permit multi-transfer through one's own territories, but the built in code automatically sets it so once you transfer back to territory you already own, all further movement ends up with result.IsSuccessful==false, and my code receives this order as a failed order (result.IsSuccessful==false).

In particular, for when the 1st movement after transferring to one's own territory happens, the following state applies:
    *game.ServerGame.LatestTurnStanding.Territories[order.From].NumArmies.NumArmies==# armies present on source territory
    *game.ServerGame.LatestTurnStanding.Territories[order.To].NumArmies.NumArmies==# armies present on target territory (owned by same player as source territory)
    *order.NumArmies.NumArmies==# of armies the player actually selected to move from source territory to the target territory
    *result.ActualArmies.NumArmies==0 --> this is a problem, b/c it's decided that despite the user trying to move units, it's reduced the # that actually move to 0
    *result.IsSuccessful==false --> also a problem, and likely the reason why the ActualArmies is set to 0


I've tried skipping this order and adding another order with the figures I need to occur, but the same rules apply and the same result happens again.

IsSuccessful seems to a read only variable, so I can't just change it and force the movement to be allowed.

The problem is that by the time the Order comes to my code, it's already assigned result.IsSuccessful==false and result.ActualArmies.NumArmies==0 and I can't seem to change the result to allow the move to happen.

My code is in:
function Server_AdvanceTurn_Order(game, order, result, skipThisOrder, addNewOrder)

Is this the right spot for it?
Change result of attack/transfer: 8/30/2020 09:42:26


TBest 
Level 60
Report
‘ false to true to permit multi-transfer through one's own territories‘

Are you able to override orders that are not multi-transfers? If so this might be a restriction in warzone that mods can’t bypass.

I haven’t taken a closer look yet, but this is my first hunch and I think this could be it

Edited 8/30/2020 09:43:37
Change result of attack/transfer: 8/30/2020 10:07:45


JK_3 
Level 63
Report
@krinid I think the moving of 0 armies causes the attack to fail, instead of the fail causing the 0 armies
Change result of attack/transfer: 8/30/2020 14:16:13


(deleted) 
Level 60
Report
Is your inquiry related to this post?

https://www.warzone.com/Forum/443512-link-up-move-one

If so, make sure 'total' armies is there before you 'move' them. They have to register as a total # of armies first. Then they should be able to move as a whole group to the next territory.

Also, look at the code for the move armies window. (the little box with the slider bar) That also has to be changed to reflect the move order. If it doesn't "see" them, it can't move them.

Of course, I could be totally off my rocker, in which case, ignore ^ me.

Edited 8/30/2020 14:17:13
Change result of attack/transfer: 8/30/2020 15:34:04


krinid 
Level 62
Report
@HangFire, Yep, precisely related to that thread & the mod edit I'm working on. It does show total armies, just the code overrides the move to reject it and auto-skip it. See next response to JK_3 as well.

@JK_3, Possibly, but either way I can't seem to change it. By the time my code gets the moves, the # of ActualArmies is set to 0 despite it clearly showing that the # of armies the player selected is >0 and that there are actually >0 on the source territory. There's no reason the move can't occur other than that the code has presumably identified it as a post transfer move through one's own territory and thus overrides the move to disallow it.

@TBest, No, both result.ActualArmies.NumArmies & result.IsSuccessful seem to be read only properties, so all I can do is Skip this current order and add another new order of my choosing -- but my choosing ends up being the same parameters the player originally sent, and it sends this new order through the same core code and gets rejected in the same manner. I need to be able to modify the code or at least override the code that rejects this order. Surely this is possible? Does any other mod we know change the success/failure criteria of an attack? Not just Skip and recreate a different one, but actually flip the Allow/Reject status one way or the other?

I considered that since I've already recognized this as a post transfer move through one's own territory, I could just manually edit the # of armies in the FROM and TO territories ... but this is actually only feasible for Transfers where it's a simple take from FROM territory and add to TO territory, but it could well be an Attack, in which case I really need to let the core WZ engine handle it to deal with all the facets of of battle (kill rates, cards, other mods, etc). Else I'd have to radically simplify the attack which ruins the game and would ignore several facets of play and make a straight up attack differ from an attack after a transfer through own territory, which makes the mod kind of meaningless.

So in essence I believe I can handle multi-transfers, and also straight up multi-attacks, just not mixed multi-attacks after a transfer.
Change result of attack/transfer: 8/30/2020 15:44:03


JK_3 
Level 63
Report
I forgot when the server calls which function, but perhaps it would be possible to call a function that happens before the turn gets calculated by the server.

That way you could manually subtract the #armies in A and B and add them to C, then let the server take it from there.
This would prob require attack by % to work, so all the armies attack instead of just the few that were in C originally.
Change result of attack/transfer: 8/30/2020 18:20:14


(deleted) 
Level 60
Report
krinid, what if you changed the value to n? Would it still default to 0 for the second transfer?

Odd that a 2nd transfer will show the total number of armies there, yet ignore the merge to move them.

Just a thought. Maybe it needs to show two results. Could be why the second transfer is ignored because it doesn't recognize it as a result. You need two results for a merge?

Edited 8/30/2020 18:22:44
Change result of attack/transfer: 8/30/2020 22:47:58


krinid 
Level 62
Report
@JK, Agree with you, but unfortunately I'm not slick enough with the API to know which function that would be, or if it even exists ... does any other mod materially change how an attack works that it would change the outcome? I know there are a number of mods that are independent attacks of their own like Nuke, Pestilence ... and those are honestly easier b/c they aren't changing existing moves, they are actually new moves of their own with manual adjustments that ignore all other attack factors or cards (eg: you can Nuke or cast Pestilence someone you can't attack b/c of a Diplo card, etc). And b/c these "attacks" are unique and materially different from regular attacks, this can be deemed acceptable, but what I'm trying to do here is in fact a regular attack, so it needs to go through the same code to be consistent.

Actually goes along with another idea I have for a mod, which is to modify kill rates based on in-game stateful criteria, so it would necessary for that as well.

@HangFire, It doesn't work that way. The # of armies shows the intended moved # of armies, but the ActualArmies shows the resultant # of armies that will actually make the attack. Adding a new order with different #'s doesn't change the fact that the game code knows that it just did a transfer ... I need to somehow trick the game into not knowing that these units transferred before this attack move.
Change result of attack/transfer: 9/1/2020 14:03:11


krinid 
Level 62
Report
I'll take a look at Stack Limit ... I think this might have clues. Not 100% sure but I think this mod prevents you from having a stack beyond a set limit of x, so if you move units to a target territory which could result in that exceeding x, it leaves the excess units behind.

Though I think this would never happen during an attack (can never increase units after an attack unless someone writes a mod to permit negative kill rates), and if it's only during transfers, it's possible that it's handled in the same mechanism I illustrated above (manually modifying the unit counts on FROM and TO territories).
Change result of attack/transfer: 9/1/2020 14:59:04


(deleted) 
Level 60
Report
This mod, prevents territories from crossing a customizable amount of armies on it. If you deploy armies, make sure they don't go over the army limit, since that will delete those that go over the cap. Same goes for the game creation(so if you make e.g. custom scenario or set starting armies per territory, verify that those are not over the limit). You don't have to worry about losing armies due to transfering, the orders will be adapted so you don't lose any.
Trusted: no
Change result of attack/transfer: 9/1/2020 16:18:48


TBest 
Level 60
Report
Figured it out. Easier then I expected too :) I guess Warzone just sets ActualArmies to 0 when the armies have been 'spent'.


function Server_AdvanceTurn_Order(game, order, result, skipThisOrder, addNewOrder)
    if (order.proxyType == 'GameOrderAttackTransfer') then
        if (result.IsAttack == false) then
            local attackers = 100 --Maybe you have to get the proper number here from the territory. But 100 is fine for this example
            --Write to GameOrderResult	 (result)
			local NewAttackingArmiesKilled = WL.Armies.Create(attackers) 
            result.ActualArmies  = NewAttackingArmiesKilled
        end;
    end
end


Change result of attack/transfer: 9/1/2020 17:58:02


(deleted) 
Level 60
Report
As long as ^ that, leads to this

> "move 10 troops from A into C, and 10 from B into C, and then from there, advance all 20 into the next territory."

A >10
........C >20 --->D20
B >10

^ That is what we want.
Change result of attack/transfer: 9/1/2020 19:04:07


TBest 
Level 60
Report
Sure does. Same principle. (I did test it to make sure too)
Change result of attack/transfer: 9/3/2020 14:14:28


(deleted) 
Level 60
Report
Release date? I have a scenario ready for testing.
Change result of attack/transfer: 9/3/2020 14:16:18


krinid 
Level 62
Report
If it works as smoothly as that, should be 1-2 weeks. Just need time to finish the testing ... I seem to recall setting that value and having it ignored, but let me take another look & will report back.

And TBest said he tested it and it worked, so should be just a matter of figuring out what I did wrong the first time I tried it and adjusting to how TBest did it.

#TBest_knows_Best!

Edited 9/3/2020 14:18:12
Change result of attack/transfer: 9/3/2020 14:54:20


(deleted) 
Level 60
Report
O.k., two weeks. Good enough. Thank you.
Change result of attack/transfer: 9/6/2020 04:16:01


krinid 
Level 62
Report
TBest - Can you pls send the contents of the whole LUA file you are testing with? I'm unable to replicate the results you're getting.

I can confirm that it properly updates the value for result.ActualArmies but result.IsSuccessful still ==false, and the turn never actually ends.

I have some print statements in function Server_AdvanceTurn_End to visually signal when the turn is ending, and as long as the 'result.ActualArmies = NewAttackingArmiesKilled' line is executed, this code never executes, the turn never ends and the move is never executed in the game UI. If I remove this line, the print line displays and the turn ends normally.
Change result of attack/transfer: 9/8/2020 22:46:51


(deleted) 
Level 60
Report
So, howzit goin with the mod?
Change result of attack/transfer: 9/9/2020 00:13:21


krinid 
Level 62
Report
I'm stuck b/c I can't figure out any way past the problem I stated previously and can't replicate TBest's solution to it.
Change result of attack/transfer: 9/9/2020 00:53:51


(deleted) 
Level 60
Report
edit. nvm.

Edited 9/9/2020 00:54:54
Posts 1 - 20 of 36   1  2  Next >>