Duke4.net Forums: Trying to start fake Coop Game - Duke4.net Forums

Jump to content

Hide message Show message
Welcome to the Duke4.net Forums!

Register an account now to get access to all board features. After you've registered and logged in, you'll be able to create topics, post replies, send and receive private messages, disable the viewing of ads and more!

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Trying to start fake Coop Game

User is online   Trooper Dan 

  • Duke Plus Developer
  • 2,141

#1

I want to try coding a coop player AI that works by manipulating the input of an actual player (not a useractor that mimics a player).

I thought I would start with the built-in fake multiplayer, just to get a game going with a bot in it. Looking at the console commands, it would seem that these commands are the ones I want:

-q2 // two players total
-a // use fake multiplayer

Starting the game with those commands, I can get as far as configuring the game settings and launching the game, but then it gets stuck on the "waiting for votes" screen. Unfortunately, the bot never votes and I don't know how to skip past that screen and get into the game.

Please help!

EDIT: I can force the game to start in a specific episode or map by adding that to the command line. Not the ideal solution, since I want to be able to choose without editing the command line. But more importantly, the player is instantly squished when starting every time. Is this a known issue with the newest build?


This post has been edited by Trooper Dan: 04 September 2017 - 06:00 PM

0

User is online   Trooper Dan 

  • Duke Plus Developer
  • 2,141

#2

I have a workaround for the non-voting bot problem (force episode to start via command line) and another workaround for the squish on start problem (temporary god mode).

Now I have a simple question: Once the game is running in coop mode with one human player and a bot player, what do I check in the APLAYER actor to tell whether the current actor is the human player or the bot? (please note that I want a solution to work with an arbitrary number of bots and human players joining and leaving the game at any time).

UPDATE: Another serious problem is that the fake multiplayer game always starts with every single player spawn point occupied by an actual player sprite. Only the bot one is visible, but the others are still there and blocking. If you shoot them, the human player acts like he's taking damage.

I had hoped to avoid using OldMP, because this project (at least at the outset) doesn't require real multiplayer, and I don't want to go back in time with CON and other features.


This post has been edited by Trooper Dan: 04 September 2017 - 07:59 PM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!
  • 4,182

#3

I use the following bat files to start DM and Coop games:
@echo off 
eduke32.exe -q8 -m -map _ZOO.MAP -c1 -noconsole -c "exit"
CLS
EXIT

@echo off 
eduke32.exe -q8 -map _ZOO.MAP -c2
CLS
EXIT


View PostTrooper Dan, on 04 September 2017 - 07:01 PM, said:

UPDATE: Another serious problem is that the fake multiplayer game always starts with every single player spawn point occupied by an actual player sprite. Only the bot one is visible, but the others are still there and blocking. If you shoot them, the human player acts like he's taking damage.

You have to start multiplayer with the maximum players per map. If I am not mistaken, the code was modified to let players join a game already running, so the number of players is set to the limit when the code starts, but the code is unfinished and cause issues.

This post has been edited by Fox: 05 September 2017 - 12:03 AM

0

User is online   Trooper Dan 

  • Duke Plus Developer
  • 2,141

#4

Thanks, I did end up adding more parameters, very much like your example. However, starting with max players seems like a non-solution. I figured out a way to use EVENT_PROCESSINPUT to detect which is the human player, which are the bots, and which are the placeholder dummies. The dummies can then be deleted before the human knows about it.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!
  • 4,182

#5

The correct way to detect the players is using the MULTIMODE and numplayers vars. The yvel of bots is >= numplayers. The yvel of dummies is >= MULTIMODE.

This post has been edited by Fox: 05 September 2017 - 01:28 AM

1

User is online   Trooper Dan 

  • Duke Plus Developer
  • 2,141

#6

I'm asking for some help from anyone who is familiar with the source code. As I said above, I'm starting a project of making my own bots. Now I've run into a problem. The input struct member extbits is set based on the movement keys the player is pressing. I had hoped that by setting that member appropriately on a bot player, it would cause the bot to move. Unfortunately, that is not the case. What I actually have to do is directly set the members fvel and svel, which are velocities. What I'm looking for is how to translate the movement inputs into the resulting fvel and svel values over time. From a script coding standpoint, what I'd like to do is code which movement keys the bot is pressing, then use that info to update the fvel and svel on the bot. I'm not sure where to look in the source code for how the input values are used to update the velocities, or even if the code is in more than one place.

EDIT: Nevermind, I think I was confused about some stuff when I wrote that and need to figure it out for myself.


This post has been edited by Trooper Dan: 09 September 2017 - 08:56 PM

0

User is online   Trooper Dan 

  • Duke Plus Developer
  • 2,141

#7

OK, I think I understand what to ask now.

    localInput.fvel = mulscale9(staticInput.fvel, sintable[(pPlayer->ang + 2560) & 2047]) +
                      (mulscale9(staticInput.svel, sintable[(pPlayer->ang + 2048) & 2047]));

    localInput.svel = mulscale9(staticInput.fvel, sintable[(pPlayer->ang + 2048) & 2047]) +
                      (mulscale9(staticInput.svel, sintable[(pPlayer->ang + 1536) & 2047]));


The fvel and svel results which are set by the code above will actually make a player move. Through CON I can access the player's angle and there is a sin function and mulscale function....so far, so good. But this also uses staticInput.fvel and staticInput.svel, for which there do not seem to be any corresponding members accessible in CON. If the static input is the actual keypresses, then it would seem to correspond to the extbits member. But I'm not sure what to make of it. Can anyone help?

EDIT: More pieces of the puzzle:

#define NORMALKEYMOVE 40
#define MAXVEL       ((NORMALKEYMOVE*2)+10)
#define MAXSVEL      ((NORMALKEYMOVE*2)+10)


    if (BUTTON(gamefunc_Strafe_Left) && !(g_player[playerNum].ps->movement_lock & 4))
        staticInput.svel += keyMove;

    if (BUTTON(gamefunc_Strafe_Right) && !(g_player[playerNum].ps->movement_lock & 8))
        staticInput.svel += -keyMove;

    if (BUTTON(gamefunc_Move_Forward) && !(g_player[playerNum].ps->movement_lock & 1))
        staticInput.fvel += keyMove;

    if (BUTTON(gamefunc_Move_Backward) && !(g_player[playerNum].ps->movement_lock & 2))
        staticInput.fvel += -keyMove;


So it looks like the staticInput values increase or decrease each tic by increments of NORMALKEYMOVE up to the defined max/min values. Pressing forward yields positive staticInput.fvel and backwards is negative. Strafing left is positive staticInput.svel and strafing right is negative. This should be enough information now to try to make a CON equivalent for bots.


This post has been edited by Trooper Dan: 10 September 2017 - 01:29 AM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!
  • 4,182

#8

As silly as it sounds, in multiplayer the game shares the player movements, not key presses. So it's possible in the vanilla game to cheat by increasing the player velocity.

If I understand it, staticInput is used by controllers with a sliding scale of movement (as opposed to a keyboard key). It should be of little relevance for what you are doing.
0

User is online   Trooper Dan 

  • Duke Plus Developer
  • 2,141

#9

View PostFox, on 10 September 2017 - 07:52 AM, said:

As silly as it sounds, in multiplayer the game shares the player movements, not key presses. So it's possible in the vanilla game to cheat by increasing the player velocity.

If I understand it, staticInput is used by controllers with a sliding scale of movement (as opposed to a keyboard key). It should be of little relevance for what you are doing.


Maybe I was reading it wrong, but I thought that staticinput could come from different sources, depending on what the player is using. In any case, I have to have something to feed into the functions that return fvel and svel.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks are property of their respective owners. Yes, our forum uses cookies. © 2017 Voidpoint, LLC

Enter your sign in name and password


Sign in options