if i assign "players.usercmd" to a variable, who does that usercmd refer to exactly ? noone? is it "empty"? do i have to bind it to a player to work? in PlayerRunCommand this happens automatically, correct?
thanks anybody for clarification
players.usercmd and PlayerRunCommand
- L'In20Cible
- Project Leader
- Posts: 1534
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: players.usercmd and PlayerRunCommand
Could you please elaborate?
Re: players.usercmd and PlayerRunCommand
ok, i am in csgo.
i do create_fake_client
i spawn the "Player"
then i listen in on
the issue:
1) this command "seems to work" with playerbuttons.JUMP. but if i replace "JUMP with PlayerButtons.ATTACK, it will not always works.
2) moreover, if i reload the script the ucmd doesn't work at all. ( so it basically only works for the first scriptload after i started the server and only after an unknown amount of time ).
ive found that
https://github.com/Source-Python-Dev-Te ... n.cpp#L360
(on scriptload)
is when the runcommandlistener gets assigned to the player
https://github.com/Source-Python-Dev-Te ... s.cpp#L194
but i don't know where that usercmd
https://github.com/Source-Python-Dev-Te ... s.cpp#L190
comes from, so i am wondering , if i have to initiate/assign a usercmd from sourcepython for the newly create fake_client object.
but idk if the issue is with the usercmd at all.
in the end all i'd want is for @OnPlayerRunCommand to work with create_fake_client correctly.
i do create_fake_client
Code: Select all
newfakeclient = engines.server.engine_server.create_fake_client(name)
bot_ptr = entities.helpers.pointer_from_edict(newfakeclient)
bot = memory.make_object(players.entity.Player, bot_ptr)
i spawn the "Player"
Code: Select all
bot.spawn()
then i listen in on
Code: Select all
@OnPlayerRunCommand
def PlayerRunCommand(player, ucmd):
if player.is_bot():
ucmd.buttons = random.choice([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,PlayerButtons.JUMP])
the issue:
1) this command "seems to work" with playerbuttons.JUMP. but if i replace "JUMP with PlayerButtons.ATTACK, it will not always works.
2) moreover, if i reload the script the ucmd doesn't work at all. ( so it basically only works for the first scriptload after i started the server and only after an unknown amount of time ).
ive found that
https://github.com/Source-Python-Dev-Te ... n.cpp#L360
(on scriptload)
is when the runcommandlistener gets assigned to the player
https://github.com/Source-Python-Dev-Te ... s.cpp#L194
but i don't know where that usercmd
https://github.com/Source-Python-Dev-Te ... s.cpp#L190
comes from, so i am wondering , if i have to initiate/assign a usercmd from sourcepython for the newly create fake_client object.
but idk if the issue is with the usercmd at all.
in the end all i'd want is for @OnPlayerRunCommand to work with create_fake_client correctly.
- L'In20Cible
- Project Leader
- Posts: 1534
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: players.usercmd and PlayerRunCommand
Fake clients created by engine_server.create_fake_client are empty shells. They are CCSPlayer instances rather than CCSBot meaning they won't do anything unless they are instructed to do so. If your goal is to force a fake client to perform actions, you need to use a controller. For example:
Now that bot should attack until instructed to do otherwise. Changing the buttons into a OnPlayerRunCommand callback is most likely too late to override some actions. Besides, they are more than likely broken and incomplete and you may have more success by using real bots and override their think methods.
Syntax: Select all
from players.bots import BotCmd
from players.bots import bot_manager
from players.constants import PlayerButtons
edict = bot_manager.create_bot('Foo')
bcmd = BotCmd()
bcmd.buttons |= PlayerButtons.ATTACK
controller = bot_manager.get_bot_controller(edict)
controller.run_player_move(bcmd)
Now that bot should attack until instructed to do otherwise. Changing the buttons into a OnPlayerRunCommand callback is most likely too late to override some actions. Besides, they are more than likely broken and incomplete and you may have more success by using real bots and override their think methods.
Re: players.usercmd and PlayerRunCommand
i am pretty sure i have tried that too. ayuto had a replay bot that used a controller with botcmd. but when i tried using the bcmd and controller nothing happened. i will try that route again and report back. thank you for now
Re: players.usercmd and PlayerRunCommand
oh i see. i found my mistake.
i have to callfor every tick i want to play the altered bcmd in. i previously only changed the .buttons per tick and then tried to access it via onplayerruncommand but that dropped me into a recursive loop crash.
thank you. i think it works now this way.
i have to call
Code: Select all
controller.run_player_move(bcmd)
thank you. i think it works now this way.
- L'In20Cible
- Project Leader
- Posts: 1534
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: players.usercmd and PlayerRunCommand
A good example would be the plugin samples shipped with the sdk: ../utils/serverplugin_sample/serverplugin_bot.cpp. Tho most likely outdated and broken on recent games.
Who is online
Users browsing this forum: No registered users and 14 guests