Zombies Run, Zombies Walk, but can Zombies Jog?

Discussion in 'Scripting Discussions' started by clifdayz, Jan 18, 2016.

  1. clifdayz

    clifdayz Well-Known Member

    Joined:
    Jul 28, 2015
    Messages:
    119
    Likes Received:
    8
    so making them walk is easy "_agent forceSpeed 2;" in zombie_agent.fsm, blah, blah, blah.

    So I was thinking I'd speed them up a bit to make them a little harder. Well, "_agent forceSpeed 3;" seems to make them full speed. There seems to be another spot in zombie_wildagent.fsm but changing that didn't help either. I looked around and the posts I see are all epoch but all suggest it can be done.
    Is this possible in vanilla 1.8.6.1?
     
  2. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,415
    Likes Received:
    336
    was just thinking same thing. walking zombies are worthless, i wanted to randomize the speed with walk, stroll, jog and run. i know i tries to make them run faster than 10 and that had no effect.
    will work on it this afternoon
     
  3. zedmag

    zedmag Member

    Joined:
    Jul 17, 2013
    Messages:
    40
    Likes Received:
    3
    Pretty sure it's based on the animations available. There is no real 'jog' animation like the player has. I would lower them to a walk, but multiply the amount to compensate.
     
  4. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,415
    Likes Received:
    336
    Thats what he was saying. if he sets forcespeed 2, they walk. if he sets forcespeed 3, they are normal running speed, there is no method of in between speeds. I think they have the same basic functions as the player and AI since the zombies are just reskinned AI units. So they have a walk, crouch, prone, run, sprint. But their 'run' seems to be the same as the players 'sprint' since you cant outrun them.
    If you know of, or can devise some way to manipulate speed other than forcespeed then let us know. I for one would love to see them vary speeds and have some run FASTER than players. I think the only way to do this would be to use a setpos after each frame and either advance or reverse the zombie location. (I guess this is what you are meaning when you say to multiply the amount).
    So if you want this zombie to go at 70% of a full run, this code would have to run every frame for somewhat smooth movement:
    zombie last location
    get zombie location
    interpolate the revised zombie location by determine the distance traveled and then adjust it by the speed %
    zombie setpos newpos
    save zombie position to be used in next frame

    So using this method we could make a zombie run faster by basically teleporting small increments every frame.
     
  5. clifdayz

    clifdayz Well-Known Member

    Joined:
    Jul 28, 2015
    Messages:
    119
    Likes Received:
    8
    ok, so they can't jog, but going off your idea, I think I'll make some % of them run. I'll have to play around and see what I can use in the FSM.
     
    Last edited: Jan 26, 2016
  6. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,415
    Likes Received:
    336
    yeah. i thought in the fsm just adding a randomizer switch statement for different speeds when they switch to chase.
     
  7. clifdayz

    clifdayz Well-Known Member

    Joined:
    Jul 28, 2015
    Messages:
    119
    Likes Received:
    8
    ok for context, here's the new changes to zombie_agent.fsm .
    I wasn't sure which RAND-type function I could use, so I found a similar usage farther down in the file.
    This was my first cut. Running on my test server where 20 zombies will swarm me, you just get a few runs at you now and again. It needs to be turned up a bit, but I like it. I assume now that this code gets executed whenever a zombie decides to chase you, so you get uneven runs now and again.


    Code:
       class Chase
        {
          name = "Chase";
          init = /*%FSM<STATEINIT""">*/"_timeN = diag_tickTime;" \n
           "" \n
           "_last = _agent getVariable[""lastAttack"", 0];" \n
           "_entHeight = (getPosATL _agent) select 2;" \n
           "_pHeight = (getPosATL _target) select 2;" \n
           "_delta = _pHeight - _entHeight;" \n
           "" \n
           "_chance =    round(random 100);" \n
           "if ((_chance % 33) == 0) then {" \n
          "    _agent forceSpeed (_agent getVariable [""speedLimit"", 3]);" \n     
           "} else {" \n
           "    _agent forceSpeed 2;" \n
           "};" \n
    
    
    ....more code down here .....
    
    
     
    ShootingBlanks likes this.
  8. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,415
    Likes Received:
    336
    "_chance = round(random 100);" \n
    "if ((_chance % 33) == 0) then {" \n

    You are getting a random number between 0 and 100. Lets say its 47.
    Am I wrong? the % is the modulus operator which divides the numbers and gives you the remainder?
    Now on next line if 47 / 33 = 1 with remainder of 14 ... so it will ONLY == 0 if the random number is 33.

    I would think what you are looking for is this to give 1/3 of the zombies running.
    if _chance < 33 then ...
     
  9. clifdayz

    clifdayz Well-Known Member

    Joined:
    Jul 28, 2015
    Messages:
    119
    Likes Received:
    8
    You are correct. The original was in that format so I thought about it a bit and way back to random number theory and statistics and wondered for a few seconds if this was was better. Is rand(10) % 7 better than rand(10) <1 or rand(10) = 5 and so forth and so on. Then I just plugged a few numbers into it. lol. No matter, this will be a good addition to my server once I decide on the randomness.

    Can I finally say your relatively new avatar "pops" out at me. I mean startles me....ugh that didn't sound right!
     
  10. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,415
    Likes Received:
    336
    took me a long time to get my wife to let me take that picture of her
     
    Zeehond23 likes this.

Share This Page