Author Topic: /turret Script  (Read 887 times)

0 Members and 1 Guest are viewing this topic.

Offline STM1993

  • Rainbow Warrior
  • *****
  • Posts: 2072
  • It's been a long time.
/turret Script
« on: May 05, 2008, 08:14:43 am »
Okay, I posted this idea up in a topic in Game Improvements in one of my posts (the topic is TF2 mode!)

Before you say its just the same as /stat which summons a stationary gun, this is slightly different. I would like to know if this is possible and maybe provide the code so it can help OTHER scripters or players in any way possible.

The idea is this: when you type /turret , a stationary gun is spawned. A bot who is on your team is added. (for team games, I'm not sure how it might be done in non-team games like DM) This bot will spawn on the exact same location as the stationary gun. Now, the bot will man the turret and keep using it, firing the stationary gun at any incoming enemies he can see.

How do we destroy this turret? If the Bot ever walks out or unmans the stationary gun or if the bot is killed, the bot is instantly removed from the game, and the stationary gun itself will explode and disappear from the game. The turret may be removed by another command like /remove2 .

The above is to prevent cases in which the stat gun is placed at awkward positions, the bot actually being boosted out of the turret or the stat gun happens to be bugged and can't fire.

Some flaws:
1. If the bot sees a Flagger or Barrett or Ruger or Fists or maybe even Chainsaw, he will behave awkwardly.

2. For awkward positions, there is another problem: The stat gun, if placed at some funny angles, will fly out of place. I think one way to solve this: The bot is the one who explodes instead of the stat gun. Or, if you want it to be more fail-safe, if the Bot is at where the turret is supposed to be spawned, he explodes. If the stationary gun is at where its supposed to be but the Bot is not there, the stationary gun explodes instead. If both are together, either one explodes would do, or both trigger the explosion.

3. Also, sometimes, in some positions, the stat gun doesn't fire its bullets appropriately ; the bullets will hit the wall. So I think that the turret should be spawned at exactly where the player stands, but there is a time-limit before it spawns so that the player can move away and not man the stat gun instead of the bot, and this can cause a problem.

What do you guys think? Can it be done and what would the code be if it were done?

EDIT:
Flamingo also pointed out that waypoints can be a problem in the TF2 mode thread.
« Last Edit: May 05, 2008, 10:15:05 am by STM1993 »

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: /turret Script
« Reply #1 on: May 05, 2008, 11:38:23 am »
You don't need a bot that actually fires the stat gun, you can make the turret shoot by itself using CreateBullet and some mathematics. This solves "bot runs away"-issues. To make it still destructable, you can use my PlaceBot algorithm to place a Dummy bot at the stationary gun. He won't shoot and won't run away or anything, he just serves as the "health" of the turret.
The script can also easily check wether the chosen position is ok for placing a stat gun and if not, it can simply to some slight X Y corrections and then place it or tell the player to move somewhere else.
For an example of a self shooting turret, you can simply check out MMod for Tinker's "Sentry Gun".
« Last Edit: May 05, 2008, 11:40:00 am by Avarax »
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline STM1993

  • Rainbow Warrior
  • *****
  • Posts: 2072
  • It's been a long time.
Re: /turret Script
« Reply #2 on: May 06, 2008, 12:35:59 am »
Ohh okay. So, its just making the turret fire by itself automatically (kinda like adding an AI to the turret), while a Dummy bot is placed at the location of the stat gun so that he can't move or whatever, and simply only acts as the HP of the turret.

Hmm, and it seems like it's already made eh?
« Last Edit: May 06, 2008, 12:38:04 am by STM1993 »