Hello everyone
,
This is my very first post. Please be nice to me xD.
I am semi-experienced in programming with JASS. I learn most of it here from you
.
I'm currently working on a project. I want to build the mobile game Brotato in Warcraft with multiplayer functions.
But now I'm failing at my first spell xD xD. I would like to be able to shoot the searing arrow while running.
I've put a lot of days into it and haven't gotten any results yet. The best thing I've managed so far is definitely the damage while running and the occasional arrow hitting the opponent.
Maybe there is someone here who has the desire and time to check my code for errors or give me suggestions for improvements (tips).
Kind regards
TeKey
P.S.: as a reminder, I'm semi good at Jass :-D
This is my very first post. Please be nice to me xD.
I am semi-experienced in programming with JASS. I learn most of it here from you
I'm currently working on a project. I want to build the mobile game Brotato in Warcraft with multiplayer functions.
But now I'm failing at my first spell xD xD. I would like to be able to shoot the searing arrow while running.
I've put a lot of days into it and haven't gotten any results yet. The best thing I've managed so far is definitely the damage while running and the occasional arrow hitting the opponent.
Maybe there is someone here who has the desire and time to check my code for errors or give me suggestions for improvements (tips).
JASS:
library HeroStats // initializer FillHeroArray
globals
unit array evryhro
endglobals
function FillHeroArray takes nothing returns nothing
local unit u
local integer loopvar = 0
loop
exitwhen loopvar >= bj_MAX_PLAYERS
set u = FirstOfGroup(GetUnitsOfPlayerAll(Player(loopvar)))
loop
exitwhen u == null
if IsUnitType(u, UNIT_TYPE_HERO) then
set evryhro[loopvar] = u
endif
set u = null
endloop
set loopvar = loopvar + 1
endloop
endfunction
function IsA000Hero takes unit hero returns boolean
local integer spellId = 'A000' // Hier den ID-Code deiner Fähigkeit 'A000' einfügen
return GetUnitAbilityLevel(hero, spellId) > 0
endfunction
function getXCoordinates takes unit u returns real
return GetUnitX(u)
endfunction
function getYCoordinates takes unit u returns real
return GetUnitY(u)
endfunction
function GetHeroStat takes unit hero, integer statType returns real
local real statValue = 0.0
if statType == 1 then
// Stärke
set statValue = GetHeroStr(hero, true)
elseif statType == 2 then
// Agilität
set statValue = GetHeroAgi(hero, true)
elseif statType == 3 then
// Intelligenz
set statValue = GetHeroInt(hero, true)
endif
return statValue
endfunction
function CalculateCriticalHit takes real critChance returns boolean
local real randomValue = GetRandomReal(0.0, 1.0)
return randomValue <= critChance
endfunction
endlibrary
JASS:
library GCU
globals
endglobals
function GetNearestUnitInGroup takes unit hero, rect customRangeRect, real maxRange returns unit
local real x
local real y
local unit nearestUnit = null
local real closestDist = maxRange
local unit u
local real dist
local group units = CreateGroup()
set x = GetUnitX(hero)
set y = GetUnitY(hero)
call GroupEnumUnitsInRect(units, customRangeRect, null)
loop
set u = FirstOfGroup(units)
exitwhen u == null
if not GetPlayerAlliance(GetOwningPlayer(u), GetOwningPlayer(hero), ALLIANCE_PASSIVE) then
if GetUnitState(u, UNIT_STATE_LIFE) > 0 then
set dist = SquareRoot(Pow(x - GetUnitX(u), 2) + Pow(y - GetUnitY(u), 2))
if dist < closestDist then
set nearestUnit = u
set closestDist = dist
endif
endif
endif
call GroupRemoveUnit(units, u)
endloop
return nearestUnit
endfunction
endlibrary
JASS:
library MissileArrow // initializer InitMissileArrow
globals
private timer MissileArrowTimer
private real missileInterval = 0.5 // Anpassbare Intervalle
endglobals
private function MissileArrowAction takes unit hero returns nothing
local unit nearestEnemy
local real spellLevel = GetUnitAbilityLevel(hero, 'A000')
local real heroagi = GetHeroStat(hero, 2)
local real damage = 100.0 + heroagi + (spellLevel * spellLevel * 25.0)
local unit dummy
set nearestEnemy = GetNearestUnitInGroup(hero, gg_rct_Fight_Area, 2000.0) // Adjust the maximum range as needed
if nearestEnemy != null and GetUnitState(nearestEnemy, UNIT_STATE_LIFE) > 0 and GetUnitState(hero, UNIT_STATE_LIFE) > 0 then
//set udg_ArrowUnit = CreateUnitAtLoc(GetOwningPlayer(hero), 'duca', GetUnitLoc(hero), bj_UNIT_FACING)
set dummy = CreateUnitAtLoc(GetOwningPlayer(hero), 'duca', GetUnitLoc(hero), bj_UNIT_FACING)
call SetUnitMoveSpeed(dummy, 5000.0)
call IssueTargetOrderBJ( dummy, "attack", nearestEnemy )
//call TriggerSleepAction(.5)
if CalculateCriticalHit(spellLevel * 0.1) then
set damage = damage * 2
call show_textdamage(damage, true, nearestEnemy, hero)
else
call show_textdamage(damage, false, nearestEnemy, hero)
endif
if GetUnitState(nearestEnemy, UNIT_STATE_LIFE) <= 0.405 then
set nearestEnemy = null
endif
call RemoveUnit(dummy)
endif
endfunction
private function MissileArrowPeriodic takes nothing returns nothing
local unit hero
local group heroGroup = CreateGroup() // Create a new unit group
local integer i
set i = 0 // Initialize i
loop
exitwhen i >= bj_MAX_PLAYERS
set hero = evryhro[i]
if hero != null and IsA000Hero(hero) then
call MissileArrowAction(hero)
call GroupRemoveUnit(heroGroup, hero)
set hero = FirstOfGroup(heroGroup)
exitwhen hero == null
endif
set i = i + 1
endloop
call DestroyGroup(heroGroup)
endfunction
private function MissileArrowStart takes nothing returns nothing
set MissileArrowTimer = CreateTimer()
call TimerStart(MissileArrowTimer, missileInterval, true, function MissileArrowPeriodic)
endfunction
function InitMissileArrow takes nothing returns nothing
call MissileArrowStart()
endfunction
endlibrary
Kind regards
TeKey
P.S.: as a reminder, I'm semi good at Jass :-D