• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

So I asked ChatGPT to make a JASS code for me...

Status
Not open for further replies.
Level 4
Joined
Jul 24, 2008
Messages
19
I hope this is the right forum to post but I was curious as to how accurate this is, given it was generated by AI

I gave ChatGPT the prompt: "Can you write me a code in warcraft 3 jass for an ability that allows the caster to throw a grenade then teleport to where it lands, dealing damage in an area of effect?"

And this is what it gave me

JASS:
function AbilityExample takes nothing returns nothing
    local unit caster = GetCaster()
    local real x = GetX(caster)
    local real y = GetY(caster)
    local real z = GetZ(caster)
    local unit grenade = CreateUnit(caster, 'n001', x, y, z)
    local real speed = 10
    local real angle = 45
    local real distance = 100
    local real dx = distance * Cos(angle)
    local real dy = distance * Sin(angle)
    local real dz = 0
    local location target = Location(x + dx, y + dy, z + dz)
    local location impact = AddLocation(target, Location(0, 0, speed * TimerDt()))
    SetUnitX(grenade, GetX(impact))
    SetUnitY(grenade, GetY(impact))
    SetUnitZ(grenade, GetZ(impact))
    local group enemies = GetUnitsInRangeOfLocAll(200, impact)
    local unit u
    for u in enemies do
        UnitDamageTarget(caster, u, 50, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    end
    SetUnitX(caster, GetX(impact))
    SetUnitY(caster, GetY(impact))
    SetUnitZ(caster, GetZ(impact))
endfunction

As someone who has only used GUI, can anyone confirm if this is useable? Of course, given that needed variables need to be created. If so, this is really impressive
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
That code is invalid. The AI seems to have thrown in unsupported constructs from other programming languages.

It probably cannot comprehend the archaic limitations of JASS. It does not know about placing call keyword in front of function calls. It also does not know that JASS only supports local declarations at the top of the function body. It also made a pattern matching 'for' loop, a style of loop JASS does not support at all.
 
Level 4
Joined
Jul 24, 2008
Messages
19
That code is invalid. The AI seems to have thrown in unsupported constructs from other programming languages.

It probably cannot comprehend the archaic limitations of JASS. It does not know about placing call keyword in front of function calls. It also does not know that JASS only supports local declarations at the top of the function body. It also made a pattern matching 'for' loop, a style of loop JASS does not support at all.
That's interesting. It did admit that JASS was an old language and that if I wanted better results, I should ask it to code in LUA. Thanks for your input!
 
Status
Not open for further replies.
Top