I’m trying to create a PvP mode in workshop. I’m trying to use lobby bots to increase the number of players, but is there way to detect lobby bots?
Someone please tell me.
There isn’t a method of detecting player names that I know of, so there isn’t a way to determine a lobby bot from a real player (as far as the Workshop’s concerned). What it can detect is if the entity is a dummy bot spawned by the Workshop, but that doesn’t really help.
Blizzard doesn’t really seem to prioritize Workshop issues, so I doubt this’ll be a feature anytime soon, if ever.
Force bot name to something invalid “\u200b” (ZERO_WIDTH_SPACE) is best choice. wait 0.016, Check if player name is \u200b, if true = then server bot, if not then is a player or dummy
// change variable number here to prevent conflicts
// or declare one manually in workshop UI,
// then just copy only the rule without variables block
variables {
player:
0: isServerBot
}
rule ("detect server bot") {
event {
Ongoing - Each Player;
All;
All;
}
conditions {
Has Spawned(Event Player) == True;
Is Dummy Bot(Event Player) == False;
}
actions
{
// where is "" is not an empty string!!! Is a zero width space, you cannot see.
// Its invisible character
Start Forcing Dummy Bot Name(Event Player, Custom String("", Null, Null, Null));
Wait(0.016, Ignore Condition);
// same here ""
If(Compare(Custom String("{0}", Event Player, Null, Null), ==, Custom String("", Null, Null, Null)));
Set Player Variable(Event Player, isServerBot, True);
End;
Wait(0.016, Ignore Condition);
Stop Forcing Dummy Bot Name(Event Player);
}
}
This will work because:
- Player cannot be have custom name
- Is dummy will return false for server bots
- Setting to something invalid (like \u200b unicode char, will not conflict with player names)
Extra tips & help check in https://workshop.code docs:
https://workshop.codes/wiki/articles/detect-ai-bots(Detect AI bots wiki)
Sorry, Apparently it didn’t work. Do you have the actual code?
Yeah, use this share code QA4T2 for testing.
Source code of overpy code i’ve used for QA4T2 code:
- You can copy the rule
"detect server bot"and reuse in other codes.
#!disableOptimizations
settings {
"main": {
"description": "This code show how to detect server-side controlled bots.",
"modeName": "DETECT SERVER BOT"
},
"lobby": {
"allowPlayersInQueue": true,
"mapRotation": "afterGame",
"ffaSlots": 10,
"returnToLobby": "afterGame",
"swapTeamsAfterMatch": false
},
"gamemodes": {
"ffa": {
"enabledMaps": [
"blackForest"
],
"tankPassiveHealthBonus": "alwaysEnabled"
},
"general": {
"enableHeroSwitching": false,
"healthPackRespawnTime%": 50,
"heroLimit": "off",
"enableKillCam": false,
"enableRandomHeroes": true,
"spawnHealthPacks": "enabled"
}
}
}
playervar isServerBot
rule "detect server bot":
@Event eachPlayer
@Condition eventPlayer.hasSpawned()
# Dont detect dummies here!
@Condition eventPlayer.isDummy() == false
eventPlayer.startForcingName("\u200b")
wait()
# Setting variable direct without this if/else block sometimes don't work.
if "{}".format(eventPlayer) == "\u200b":
eventPlayer.isServerBot = true
else:
eventPlayer.isServerBot = false
wait()
# Stop forcing name or you can set custom name here too.
eventPlayer.stopForcingName()
playervar _icon
rule "create icon when server bot is alive":
@Event eachPlayer
@Condition eventPlayer.hasSpawned()
@Condition eventPlayer.isAlive()
@Condition eventPlayer.isServerBot
wait(0.16, Wait.ABORT_WHEN_FALSE)
createIcon(getAllPlayers(), eventPlayer.getEyePosition() + vect(0, 0.1, 0), Icon.WARNING, IconReeval.VISIBILITY_AND_POSITION, Color.ORANGE, true)
eventPlayer._icon = getLastCreatedEntity()
rule "destroy icon when server bot is dead":
@Event eachPlayer
@Condition eventPlayer.hasSpawned()
@Condition eventPlayer.isDead()
@Condition eventPlayer.isServerBot
destroyIcon(eventPlayer._icon)
eventPlayer._icon = null
In this code every standard bot (added in lobby by host) will have an warning icon above their heads:
https://imgur.com/a/0GJMtqb (sorry for bad quality, low end PC here
)
Wow! thank you. I’ll try using it in my code right away.