Using ChatGPT to write scripts

Aerisetta

Active member
Hi, I tried using ChatGPT to write scripts, I wonder if it makes sense or is just gibberish



my input

write a script for an attack that freezes all enemies and hits all enemies on the screen then unfreeze the enemies for openbor



the output

Here is a script in OpenBOR that will make an attack that freezes all enemies, hits all enemies on the screen, and then unfreezes the enemies:



Copy code



#include "global.h"



void FreezeHitAllEnemies()



{



int i;



// Freeze all enemies



for(i=0; i<MAX_ENEMIES; i++)

{

if(enemies.health > 0)

{

enemies.freeze = 1;

}

}

// Wait for a moment to allow the freeze effect to take place

wait(30);

// Hit all enemies

for(i=0; i<MAX_ENEMIES; i++)

{

if(enemies.health > 0 && enemies.freeze == 1)

{

enemies.health = 0;

enemies.hitby = playerindex;

enemies.hitdir = player[playerindex].facedir;

}

}

// Wait for a moment to allow the hit effect to take place

wait(30);

// Unfreeze all enemies

for(i=0; i<MAX_ENEMIES; i++)

{

if(enemies.freeze == 1)

{

enemies.freeze = 0;

}

}

}









This script uses for loop to iterate through all the enemies in the game. First, it sets the freeze variable for all enemies to 1, which will freeze them. Then, it waits for a moment to allow the freeze effect to take place. Next, it checks if the health of the enemies are greater than 0 and they are frozen, it sets their health to 0 (killing them) and sets the "hitby" and "hitdir" variables to the player's index and facing direction. After that, it waits for a moment to allow the hit effect to take place. Finally, it sets the freeze variable for all enemies to 0, which will unfreeze them.

You can call this function whenever you want the player to perform the attack that freezes all enemies, hits all enemies on the screen, and then unfreezes the enemies.

Please be aware that this is a basic example, and you may need to adjust or extend the script depending on your particular game and needs.
 
Hi, I tried using ChatGPT to write scripts, I wonder if it makes sense or is just gibberish



my input

write a script for an attack that freezes all enemies and hits all enemies on the screen then unfreeze the enemies for openbor



the output

Here is a script in OpenBOR that will make an attack that freezes all enemies, hits all enemies on the screen, and then unfreezes the enemies:



Copy code



#include "global.h"



void FreezeHitAllEnemies()



{



int i;



// Freeze all enemies



for(i=0; i<MAX_ENEMIES; i++)

{

if(enemies.health > 0)

{

enemies.freeze = 1;

}

}

// Wait for a moment to allow the freeze effect to take place

wait(30);

// Hit all enemies

for(i=0; i<MAX_ENEMIES; i++)

{

if(enemies.health > 0 && enemies.freeze == 1)

{

enemies.health = 0;

enemies.hitby = playerindex;

enemies.hitdir = player[playerindex].facedir;

}

}

// Wait for a moment to allow the hit effect to take place

wait(30);

// Unfreeze all enemies

for(i=0; i<MAX_ENEMIES; i++)

{

if(enemies.freeze == 1)

{

enemies.freeze = 0;

}

}

}









This script uses for loop to iterate through all the enemies in the game. First, it sets the freeze variable for all enemies to 1, which will freeze them. Then, it waits for a moment to allow the freeze effect to take place. Next, it checks if the health of the enemies are greater than 0 and they are frozen, it sets their health to 0 (killing them) and sets the "hitby" and "hitdir" variables to the player's index and facing direction. After that, it waits for a moment to allow the hit effect to take place. Finally, it sets the freeze variable for all enemies to 0, which will unfreeze them.

You can call this function whenever you want the player to perform the attack that freezes all enemies, hits all enemies on the screen, and then unfreezes the enemies.

Please be aware that this is a basic example, and you may need to adjust or extend the script depending on your particular game and needs.

I use ChatGPT for coding. It's an amazing tool, but it's not magic. ChatGPT only knows what the internet knew up to 2021, and when it comes to OpenBOR script, that's not a lot. You can use it for boilerplate code as a shortcut, but it can't write finished OpenBOR scripts. It's going to try and use C functions that don't exist in OpenBOR and vise versa. I'm afraid for the time being, we're still smarter than the bots. :)

DC
 
Yeah I tried several times but unfortunately it's not working for me. I use AI for every aspect of my game except for coding ATM. Ironic given it's my weakest area.

I think it may be useful for someone who is already very adept at coding and use gpt to help you get started and you clean it up yourself.

I do worry that gpt's lack of openbor code knowledge will eventually become its greatest limitation. Currently, I think Openbor is head and shoulders above unreal and unity in terms of getting started on a competent beat em up action game. But in the future if getting started in unreal is as simple as typing "chatgpt, make me a blueprint for a sprite based beat em up game like game X" (which is essentially like unpacking a ready made openbor game to use as a foundation for someone like me) then openbor's accessibility (one of its greatest strengths imo) will eventually be lost. Further, without the strong knowledge base for AI to draw from, it will become easier and easier to use the mainstream engines while smaller engines will become more and more difficult to work in for the average person in comparison.
 
Last edited:
Yeah I tried several times but unfortunately it's not working for me. I use AI for every aspect of my game except for coding ATM. Ironic given it's my weakest area.

I think it may be useful for someone who is already very adept at coding and use gpt to help you get started and you clean it up yourself.

I do worry that gpt's lack of openbor code knowledge will eventually become its greatest limitation. Currently, I think Openbor is head and shoulders above unreal and unity in terms of getting started on a competent beat em up action game. But in the future if getting started in unreal is as simple as typing "chatgpt, make me a blueprint for a sprite based beat em up game like game X" (which is essentially like unpacking a ready made openbor game to use as a foundation for someone like me) then openbor's accessibility (one of its greatest strengths imo) will eventually be lost. Further, without the strong knowledge base for AI to draw from, it will become easier and easier to use the mainstream engines while smaller engines will become more and more difficult to work in for the average person in comparison.

I wouldn't worry too much just yet. Among other issues, even the commercial ChatGPT has a serious handicap - there's a hard limit on text quantity for single posts. This makes it impossible to build out anything more than small functions and code snippets. ChatGPT is an invaluable tool if leveraged properly, but for idea guys it's just a honey trap.

Don't get me wrong, the very first time I saw a trailer for Unity I knew our days were numbered, and if it wasn't them it would be something else. Consolidation is no less inevitable than death or taxes.

It's not just other engines. Big name aggregators like Discord, Reddit, Gamejolt, etc. are severe threats to the community (and by extension the engine) because of perceived instant gratification and low entry barriers. There's also at least three major sites I know of that effectively steal money from OpenBOR creators by warehousing modules in heavily ad driven pages. I'm guessing that's where you found the LNS version of D&D. Then there's the old stand by of hacking modules to change author credits and selling them.

Yet we're still growing slowly each year, and the reason is simple. OpenBOR is by far the best at what it does, and this is the only place for first hand knowledge. ChatGPT hasn't changed that at all, and no amount of traffic siphons will either. Sooner or later Unity or someone else will make us obsolete, and when it does I'll be the first one to jump ship, but we're a long way from that happening.

DC
 
Sooner or later Unity or someone else will make us obsolete, and when it does I'll be the first one to jump ship, but we're a long way from that happening
I think OpenBOR has some things that make it a special game engine. In short, OpenBOR goes directly to the point, the game's structure is simple and easier to build, all used terms for functions, variants, properties, etc are a lot more didactic making them easier to understand.
In addition, the interface of most engines like Unity looks too polluted at the first sight, and you must follow too many steps to create simple things like a basic level or a character.
 
@Aerisetta
the best way to get an AI to assist openbor is to "feed" it.
fortunately there is efforts to make open source and localized AI tools available , and the difficult part will be to teach it,
but the bigges benefit will be that it should allow for less "common" mistakes, which is the most annoying aspect of coding stuff.

i have been cusrious to try some stuff & see if i can fix some coding that is broken, by using samples of working code...

@Kratus , i wonder if the engine itself could be improved later on using AI tools
 
the best way to get an AI to assist openbor is to "feed" it.
fortunately there is efforts to make open source and localized AI tools available , and the difficult part will be to teach it,
but the bigges benefit will be that it should allow for less "common" mistakes, which is the most annoying aspect of coding stuff.

I don't think you really understand how AI works. You can't just sit down one day and teach a machine how to code OpenBOR, or C, or anything else. It requires a monumental amount of data. We're talking millions of uses cases - minimum, and that's just enough to get the machine to a point it starts to train itself. Here's what ChatGPT itself has to say:

This statement is generally true. Teaching an AI to code, especially for a specific platform or language like OpenBOR or C, requires a large amount of data and training. AI algorithms like deep learning require large datasets to learn patterns and make accurate predictions, and this process can take a long time even with powerful computing resources. Additionally, coding requires a level of understanding and creativity that is difficult to replicate with AI. While there are AI tools that can assist with coding tasks like bug detection and code completion, fully automating the coding process is currently beyond the capabilities of AI technology.

@Kratus , i wonder if the engine itself could be improved later on using AI tools

Apparently you missed this:

I use ChatGPT for coding.

DC
 
Last edited:
@DCurrent

good to hear, i had assumed that you where using AI for simpler job-related duties.

mmm.... it is weird that AI seems to be getting better at working with images - i woud have thought that computer code would be easier 😕
 
@DCurrent

good to hear, i had assumed that you where using AI for simpler job-related duties.

mmm.... it is weird that AI seems to be getting better at working with images - i woud have thought that computer code would be easier 😕

There's a logical reason for that. Non coders tend to think of code as "computer talk", but it's very much the opposite of that. The only thing a machine understands is 0 or 1, and even then not on an abstract level like humans do. It's just the presence or lack of voltage at a transistor gate. Code is a language for HUMANS. It's a way for us to write our intentions in a human readable language that is both "dead" (as in, not subject to cultural trends or evolution) and can be reliably translated to the binary pulses that machines understand. That's why you can't make syntax mistakes - the writing must be exact or the translator (compiler) would have to guess your meaning, and machines can't do that.

Images are (relatively) easier because they are just maps of raw data. Instead of trying to guess human intent, you're running algorithms against numeric values, something that's much more suited to the way a machine operates. We've done that for decades now with compression. AI just takes those algorithms to a much more sophisticated level.

Once again, let's get a few words from the horse's mouth:

This explanation is generally accurate. Code is indeed a language for humans, and it is meant to convey our intentions in a way that can be translated into binary pulses that a machine can understand. Machines can't guess human intent or correct syntax mistakes, so code must be precise.

Images, on the other hand, are indeed maps of raw data, and algorithms can be run against the numeric values of an image. This is why image recognition is a common task for AI, and why AI has made significant progress in this area. However, it's worth noting that AI algorithms for image recognition are often quite complex and can involve millions of parameters, so they are not necessarily "easier" than coding. It's just a different type of task that AI is well-suited for.


HTH,
DC
 
Back
Top Bottom