Author Topic: Auto Reload and Bot mod  (Read 2417 times)

I enjoy recreating scenes and battles in blockland using bots. But I always run into two problems that keep me from making my concepts a reality. Firstly the best guns, namely gravitycats weapons, do not reload automatically. Therefore, when a bot's clip runs out, that's it. It won't be able to shoot anymore. I was wondering if there was a line of code I could implement that could give his weapons that basic,universal, functionality. You guys are geniuses, so I figured I could ask you for some help.

The second thing that ruins my build is a bots odd inability to stand in one spot and shoot. I thought of a way to fix this, but I'm not smart enough to figure it out. You guys remember the Ability Bot's released by The Resonte? In that pack was a bot labeled 'Still'. This bot did not move, and would shoot at you.

 Anyway, I wanted bots to move to cover and shoot. I was planning on eventing a bot to go to a brick and have it's datablock changed to the still player-type so that it could just stand there and shoot. But I can't. Because it's not a player-type and doesn't come up in the 'changedatablock' list. Before you ask, yes, I HAVE tried the no-move playertype. It would work, but the bot's base code ruins it. If they see an enemy and notice that they can't move, they'll start spazzing out, ducking like forty-goin' north and losing their target a ga-jillion times in the process. It doesn't work.

However, the STILL playertype DOESN'T spaz out, and I don't know why. It will just stand there and try to kill you, not losing you or ducking at all. Like a normal person trying to snipe you from cover. My big idea was to create 'Still' versions of other player-types so that they could retain their attributes and work with that event I described up there. Only problem is that I don't know how. For instance, it's not as easy as taking the MasterCheifShooter_Playertype and just copying it and renaming it to MasterCheifShooter2. Things need to be changed up in the code to recognize the new string, and I don't know where those are.

Also, despite looking at the Still bot's code, for the life of me, I can't figure out why it doesn't WANT to move and doesn't spaz out when it can't. If I could identify the string of code doing this, I was hoping I could implement it into a modded player-type, like one of the awesome Shooter playertypes.

Would you guys care to help a brotha' out a little bit?

Haven't seen the code of either of the players, but am guessing the no move restricts WASD motion, whereas the still probably restricts all motion not including turning. The no move player tries to get itself close to player depending on your description. I'll check both of those out by tomorrow if no one else has. Think Gcat's weapons will be an easy change to remove reloading, will try to get that done tomorrow too.

you can optionally just modify the gcat ammo script to check if the firing player is an AI player and disable ammo for them in that case.

as for bots that stand still and shoot, that's the default bot AI script. you can make your own edits to it if you write a custom bot AI script (without editing the base Bot_Hole support scripts) but its not that easy to design a convincingly good AI.

the Still playertype likely removes the crouch animation and the hitbox changes when you crouch.
« Last Edit: October 10, 2016, 07:03:45 PM by Conan »

Haven't seen the code of either of the players, but am guessing the no move restricts WASD motion, whereas the still probably restricts all motion not including turning. The no move player tries to get itself close to player depending on your description. I'll check both of those out by tomorrow if no one else has. Think Gcat's weapons will be an easy change to remove reloading, will try to get that done tomorrow too.

Wow. Thanks man! Appreciate it!

you can optionally just modify the gcat ammo script to check if the firing player is an AI player and disable ammo for them in that case.

as for bots that stand still and shoot, that's the default bot AI script. you can make your own edits to it if you write a custom bot AI script (without editing the base Bot_Hole support scripts) but its not that easy to design a convincingly good AI.

the Still playertype likely removes the crouch animation and the hitbox changes when you crouch.

So uh...let's just say that I have virtually no scripting experience..how hard would it be to write a custom AI script?

So uh...let's just say that I have virtually no scripting experience..how hard would it be to write a custom AI script?
Open weapon_gun. Copy server.cs and paste it into Blockland > Base. name it "botammo.cs". Inside the file, delete everything that was there before. Paste the following:

Code: [Select]
package botAmmo
{
      WeaponImage::onFire(%this,%obj,%slot)
      {
               parent::onFire(%this,%obj,%slot);
               Announce(%obj.getClassName() SPC %obj.getDatablock());
      }
}
deactivatepackage(botammo);
activatePackage(botammo);

Save it. Start a blockland server. In the console, type exec("base/botammo.cs");. Give a gun to a bot. Get the bot to shoot the gun, possibly by joining a minigame and having it shoot at you. Everytime the bot shoots, there will be a chat message showing up. Paste what 5 of these lines say.

If you get an error, paste it.
« Last Edit: October 11, 2016, 01:59:05 PM by Perry »

So uh...let's just say that I have virtually no scripting experience..how hard would it be to write a custom AI script?
pretty difficult. ai is a difficult field in comp sci in general, and even though the AI you'd need for this is simple in comparison to the stuff researchers are doing, it still isn't super easy since debugging it and making sure it works the way you want takes time and knowledge of how to set up test cases and edge cases and such.

pretty difficult. ai is a difficult field in comp sci in general, and even though the AI you'd need for this is simple in comparison to the stuff researchers are doing, it still isn't super easy since debugging it and making sure it works the way you want takes time and knowledge of how to set up test cases and edge cases and such.
I think he means code specific to AI players.

here is a quick pseudo code:

Code: [Select]
if player is an ai:
      dont use ammo because thats stupid
      return the default parent function, which is just the default onFire

if player is not an ai:
      use ammo because its a player
      return modified onFire with ammo reduction and stuff

I think he means code specific to AI players.

here is a quick pseudo code:

Code: [Select]
if player is an ai:
      dont use ammo because thats stupid
      return the default parent function, which is just the default onFire

if player is not an ai:
      use ammo because its a player
      return modified onFire with ammo reduction and stuff
he's asking about custom ai script cause i talked about how he/someone could write a modified AI for the bots to do what he wants. if he was asking for ammo exception he would have probably asked "how would I make bots not have ammo"

Open weapon_gun. Copy server.cs and paste it into Blockland > Base. name it "botammo.cs". Inside the file, delete everything that was there before. Paste the following:

Code: [Select]
package botAmmo
{
      WeaponImage::onFire(%this,%obj,%slot)
      {
               parent::onFire(%this,%obj,%slot);
               Announce(%obj.getClassName() SPC %obj.getDatablock());
      }
}
deactivatepackage(botammo);
activatePackage(botammo);

Save it. Start a blockland server. In the console, type exec("base/botammo.cs");. Give a gun to a bot. Get the bot to shoot the gun, possibly by joining a minigame and having it shoot at you. Everytime the bot shoots, there will be a chat message showing up. Paste what 5 of these lines say.

If you get an error, paste it.

Thanks man! Gonna try this out now.

pretty difficult. ai is a difficult field in comp sci in general, and even though the AI you'd need for this is simple in comparison to the stuff researchers are doing, it still isn't super easy since debugging it and making sure it works the way you want takes time and knowledge of how to set up test cases and edge cases and such.

I kinda figured that would be hard, but all I need them to do is stand still and shoot though. At least with that, I could set up bots that won't strafe-ram you and just try to snipe you. So pretty much just the 'Still' bot, but I was hoping to carry that code onto another bot hole. Somehow, The Resonte made it so that the bot didn't WANT to move. It wasn't spazzing out like it was trying to fight invisible forces when it couldn't move. It just stood there and shot at you. It wouldn't be hard to write a script for that right? I was thinking that The Resonte had removed some lines of code somewhere that normally tell the bot to strafe-ram you or spaz out when they can't move. I just don't know where those lines of code are in the files.

Alright, so I did everything ya asked Perry. An error came up in the console talking about syntax on line 3. I checked line three and saw little # symbols appearing after WeaponImage and OnFire. Tried to highlight and copy it, but it won't let me. Is this code supposed to identify whatever weapon the bot is using and disable the ammo for that particular gun when the Ai shoots it? And when you say "paste it", where exactly? In the cs file I created? Or did you mean here to help you figure out what weapon pack I'm talking about? The weapons I wanted to disable ammo for are GCatsSpecialWeapons. I'm not opposed to going into the packs code and modifying each weapon specifically so that they auto-reload like other weapons I have. (The Warfare Pack) I'm willing to work for this. :)

Because he forgot the word 'function' before WeaponImage::onFire(%this,%obj,%slot).

Because he forgot the word 'function' before WeaponImage::onFire(%this,%obj,%slot).
Thanks pal'ly!

Now it's saying that there's an error on line 9:

Code: [Select]
deactivatepackage(##b##otammo);