- Joined
- Sep 9, 2019
- Messages
- 15
For intro --- I have 0 knowledge of vJass. I tried to "make" a trigger for a passive ability. It has 1% to proc an attribute from 3 attributes. It can give +1 strength or +1 agility or +1 intelligence. The ability has 5 level ups in total. Level 1 = 1% proc, Level 2 = 2% proc, Level 3 = 3% proc, Level 4 = 4% proc, Level 5 = 5% proc. The ability can proc on any unit.
Now the ChatGPT made this:
I think it has multiple errors. I'm not sure what can I do... Any help is appreciated <3
If you can repair this or do a GUI version. I will be grateful.
Now the ChatGPT made this:
JASS:
globals
// Define the attributes
private constant integer ATTRIBUTE_STRENGTH = 0
private constant integer ATTRIBUTE_AGILITY = 1
private constant integer ATTRIBUTE_INTELLIGENCE = 2
// Define the proc chances for each level
private constant real[] PROC_CHANCES = [0.01, 0.02, 0.03, 0.04, 0.05]
endglobals
private struct AttributeProc
// Define the proc chances for each attribute at different levels
private real[3] procChances
// The function to calculate the proc chance for a specific attribute at a given level
private static method real getProcChance(integer attribute, integer level) returns real
return PROC_CHANCES[level - 1] * I2R((attribute + 1) * 100)
endmethod
// The function to determine which attribute is proc'd
private static method integer getProcAttribute(integer level) returns integer
local real roll = GetRandomReal(0.0, 1.0)
local integer attribute = -1
if roll <= getProcChance(ATTRIBUTE_STRENGTH, level) then
set attribute = ATTRIBUTE_STRENGTH
elseif roll <= getProcChance(ATTRIBUTE_AGILITY, level) then
set attribute = ATTRIBUTE_AGILITY
elseif roll <= getProcChance(ATTRIBUTE_INTELLIGENCE, level) then
set attribute = ATTRIBUTE_INTELLIGENCE
endif
return attribute
endmethod
endstruct
private function Trigger_PassiveAbilityProc takes nothing returns nothing
local integer level = 1 // Change this to get the actual level of your passive ability
local integer attribute = AttributeProc.getProcAttribute(level)
if attribute == ATTRIBUTE_STRENGTH then
// Give +1 strength
call SetHeroStr(GetTriggerUnit(), GetHeroStr(GetTriggerUnit(), false) + 1, true)
elseif attribute == ATTRIBUTE_AGILITY then
// Give +1 agility
call SetHeroAgi(GetTriggerUnit(), GetHeroAgi(GetTriggerUnit(), false) + 1, true)
elseif attribute == ATTRIBUTE_INTELLIGENCE then
// Give +1 intelligence
call SetHeroInt(GetTriggerUnit(), GetHeroInt(GetTriggerUnit(), false) + 1, true)
endif
endfunction
private function InitTrig_PassiveAbilityProc takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddAction(t, function Trigger_PassiveAbilityProc)
endfunction
//===========================================================================
// Initialization
//===========================================================================
private function InitCustomTriggers takes nothing returns nothing
call InitTrig_PassiveAbilityProc()
endfunction
I think it has multiple errors. I'm not sure what can I do... Any help is appreciated <3
If you can repair this or do a GUI version. I will be grateful.