TheOverWhelm
Member
- Reaction score
- 16
So I've been learning structs, getting them to work, just messing with them!
Made one for heroes and I'm guessing it's highly inefficient (I'm guessing)
It basically does everything a normal hero is, the per level, the st@ stats (health, mana, agi, str, int, not one for damage or armor yet)
However, I wanted to make it so a player can choose the model of the unit (sticking with Paladins for now!) and so I made a trigger that allows players to do that from a list I've created
But an issue occurs when I want to change the unit, it requires the player to edit an attribute of the hero and THEN to change the model. A player can go straight for changing the model and it says it'll work, but it wont. This shouldn't be happening. I half-think it's something about the Struct but I dunno what, I've tried stuff and it not be working!
Here are the related things. Tell me if you want me to past the entire Struct (has some useless stuff in it!)
And I know.. I'm mixing GUI and JASS :nuts:
This JASS one changes the -C values within the struct. The GUI after this one calls this.
This next one has Events, it's done at Map Init [See right below]
Trigger - Add to C Stuff <gen> the event (Player - (Picked player) types a chat message containing Go! as An exact match)
Trigger - Add to C Stuff <gen> the event (Player - (Picked player) types a chat message containing -c as A substring)
As for the trigger itself, another system detects the SelectedUnits and keeps it updated (works like a charm)
Heroes that are being modified are paused at Init and added to the Struct and a unitgroup called ModifyingGroup.
The objective of this trigger is to find how many selected units are heroes.
The above ones work all dandy.
This next trigger is to simply set the names and the unittypes.
The issue is beyond this.
This function is here because I couldn't figure out how to do the local heroData part without having it be a local. -Shrug-
I'll understand if no one responds. It's big, can be done better, and sloppy in spots.
Thanks to anyone who helps.
Also, attaching map xD
This has been bugging me for hours.
Edit: Figured it out. Some pointers for the future would be nice though!
Made one for heroes and I'm guessing it's highly inefficient (I'm guessing)
It basically does everything a normal hero is, the per level, the st@ stats (health, mana, agi, str, int, not one for damage or armor yet)
However, I wanted to make it so a player can choose the model of the unit (sticking with Paladins for now!) and so I made a trigger that allows players to do that from a list I've created
But an issue occurs when I want to change the unit, it requires the player to edit an attribute of the hero and THEN to change the model. A player can go straight for changing the model and it says it'll work, but it wont. This shouldn't be happening. I half-think it's something about the Struct but I dunno what, I've tried stuff and it not be working!
Here are the related things. Tell me if you want me to past the entire Struct (has some useless stuff in it!)
And I know.. I'm mixing GUI and JASS :nuts:
This JASS one changes the -C values within the struct. The GUI after this one calls this.
JASS:
method PlayerModifyStuff takes unit n, string s returns nothing.
local player p = GetOwningPlayer(this.u)
local string input = SubString(s,6-1,StringLength(s)) //Inputted Value
local string modding = SubString(s,4-1,4)
local real realinput = S2R(input)
local real array r
call PingMinimap(GetUnitX(this.u),GetUnitY(this.u),2)
if realinput < 0 then
return
endif
if this.CanModifyHero == false then
call DisplayTextToPlayer(p,0,0,"You can039;t modify your hero at this time.")
return
endif
set r[0]=this.healthInit+this.manaInit+this.speedInit //1 and 2
set r[1]=150+150+350
set r[2]=r[1]-r[0]
set r[4]= this.strength+this.agility+this.intelligence
set r[5]= 40
set r[6]= r[5]-r[4]
set r[7]= this.strengthLvl+this.agilityLvl+this.intelligenceLvl
set r[8]= 6
set r[9]=r[8]-r[7]
if modding=="1" and r[0]-this.healthInit+realinput<=r[1] and realinput>= 1 then
set this.healthInit = realinput
endif
if modding=="2" and r[0]-this.manaInit+realinput<=r[1] then
set this.manaInit = realinput
endif
if modding=="3" and r[0]-this.speedInit+realinput<=r[1] then
set this.speedInit = realinput
endif
if modding=="4" and r[4]-this.strength+realinput<=r[5] then
set this.strength = realinput
endif
if modding=="5" and r[4]-this.agility+realinput<=r[5] then
set this.agility = realinput
endif
if modding=="6" and r[4]-this.intelligence+realinput<=r[5] then
set this.intelligence=realinput
endif
if modding=="7" and r[7]-this.strengthLvl+realinput <= r[8] then
set this.strengthLvl = realinput
endif
if modding=="8" and r[7]-this.agilityLvl+realinput <= r[8] then
set this.agilityLvl = realinput
endif
if modding=="9" and r[7]-this.intelligenceLvl+realinput <= r[8] then
set this.intelligenceLvl = realinput
endif
call ClearTextMessages()
set r[0]=this.healthInit+this.manaInit+this.speedInit //1 and 2
set r[1]=150+150+350
set r[2]=r[1]-r[0]
set r[4]= this.strength+this.agility+this.intelligence
set r[5]= 40
set r[6]= r[5]-r[4]
set r[7]= this.strengthLvl+this.agilityLvl+this.intelligenceLvl
set r[8]= 6
set r[9]=r[8]-r[7]
call DisplayTimedTextToPlayer(p,0,0,170,"-C 1 "+R2S(this.healthInit)+" - Default HP")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 2 "+R2S(this.manaInit)+" - Default MP")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 3 "+R2S(this.speedInit)+" - Default Speed")
call DisplayTimedTextToPlayer(p,0,0,170,"You have "+I2S(R2I(r[2]))+" points left in this category.")
call DisplayTimedTextToPlayer(p,0,0,170," ")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 4 "+R2S(this.strength)+ " strength.")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 5 "+R2S(this.agility)+ " agility.")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 6 "+R2S(this.intelligence)+ " intelligence.")
call DisplayTimedTextToPlayer(p,0,0,170,"You have "+I2S(R2I(r[6]))+ " points left in this category.")
call DisplayTimedTextToPlayer(p,0,0,170," ")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 7 "+R2S(this.strengthLvl)+" strength per level.")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 8 "+R2S(this.agilityLvl)+" agility per level.")
call DisplayTimedTextToPlayer(p,0,0,170,"-C 9 "+R2S(this.intelligenceLvl)+" intelligence per level.")
call DisplayTimedTextToPlayer(p,0,0,170,"You have "+I2S(R2I(r[9]))+" points left in this category.")
call DisplayTimedTextToPlayer(p,0,0,170," ")
call DisplayTimedTextToPlayer(p,0,0,170,"When done type 039;Go!039;")
call this.FixHero() //Sets the attributes, etc
if s == "Go!" then
set this.CanModifyHero = false
call ClearTextMessages()
endif
endmethod
This next one has Events, it's done at Map Init [See right below]
Trigger - Add to C Stuff <gen> the event (Player - (Picked player) types a chat message containing Go! as An exact match)
Trigger - Add to C Stuff <gen> the event (Player - (Picked player) types a chat message containing -c as A substring)
As for the trigger itself, another system detects the SelectedUnits and keeps it updated (works like a charm)
Heroes that are being modified are paused at Init and added to the Struct and a unitgroup called ModifyingGroup.
The objective of this trigger is to find how many selected units are heroes.
Trigger:
- C Stuff
- Events
- Conditions
- Multiple ConditionsOr - Any (Conditions) are true
- Conditions
- (Substring((Entered chat string), 1, 3)) Equal to (==) -c
- (Substring((Entered chat string), 1, 3)) Equal to (==) -C
- (Entered chat string) Equal to (==) Go!
- Conditions
- Multiple ConditionsOr - Any (Conditions) are true
- Actions
- Set TempInteger = 0
- Set TempUnit = No unit
- Unit Group - Pick every unit in SelectedUnits[(Player number of (Triggering player))] and do (Actions)
- Loop - Actions
- Custom script: call BJDebugMsg(I2S(GetUnitUserData(GetEnumUnit())))
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Custom value of (Picked unit)) Greater than (>) 0
- Then - Actions
- Set TempInteger = (TempInteger + 1)
- Set TempUnit = (Picked unit)
- Else - Actions
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Custom script: call BJDebugMsg("PickingUnits")
- Custom script: call BJDebugMsg(I2S(GetUnitUserData(GetEnumUnit())))
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- TempInteger Equal to (==) 0
- Then - Actions
- Game - Display to (All players) for 10.00 seconds the text: No hero selected.
- Else - Actions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- TempInteger Equal to (==) 1
- Then - Actions
- Set TempString = (Entered chat string)
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (TempUnit is paused) Equal to (==) True
- (TempUnit is in ModifyingGroup) Equal to (==) True
- (Entered chat string) Equal to (==) Go!
- Then - Actions
- Unit - Unpause TempUnit
- Unit Group - Remove TempUnit from ModifyingGroup
- Else - Actions
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Custom script: call PassC(udg_TempUnit,udg_TempString)
- Custom script: call BJDebugMsg("TalkingToSystem")
- Set TempString = (Entered chat string)
- Else - Actions
- Game - Display to (All players) for 10.00 seconds the text: Multiple heroes det...
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Loop - Actions
- Custom script: call BJDebugMsg("You typed something!")
The above ones work all dandy.
This next trigger is to simply set the names and the unittypes.
Trigger:
- AvailableHeroList
- Events
- Time - Elapsed game time is 0.50 seconds
- Conditions
- Actions
- Set TempInteger = 1
- Set sysChoosableHeroes[TempInteger] = Uther
- Set sysRecognizedName[TempInteger] = Uther
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Admiral Proudmoore
- Set sysRecognizedName[TempInteger] = Admiral Proudmoore
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Arthas
- Set sysRecognizedName[TempInteger] = Arthas
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Dagren the Orcslayer
- Set sysRecognizedName[TempInteger] = Dagren
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Halahk the Lifebringer
- Set sysRecognizedName[TempInteger] = Halahk
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Lord Nicholas Buzan
- Set sysRecognizedName[TempInteger] = Buzan
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Magroth the Defender
- Set sysRecognizedName[TempInteger] = Magroth
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Sir Gregory Edmunson
- Set sysRecognizedName[TempInteger] = Gregory
- -------- --------
- Set TempInteger = (TempInteger + 1)
- Set sysChoosableHeroes[TempInteger] = Paladin
- Set sysRecognizedName[TempInteger] = Paladin
- Events
The issue is beyond this.
Trigger:
- ChangeHero
- Events
- Player - Player 1 (Red) types a chat message containing -change as A substring
- Player - Player 2 (Blue) types a chat message containing -change as A substring
- Player - Player 3 (Teal) types a chat message containing -change as A substring
- Player - Player 4 (Purple) types a chat message containing -change as A substring
- Player - Player 5 (Yellow) types a chat message containing -change as A substring
- Player - Player 6 (Orange) types a chat message containing -change as A substring
- Player - Player 7 (Green) types a chat message containing -change as A substring
- Player - Player 8 (Pink) types a chat message containing -change as A substring
- Player - Player 9 (Gray) types a chat message containing -change as A substring
- Player - Player 10 (Light Blue) types a chat message containing -change as A substring
- Player - Player 11 (Dark Green) types a chat message containing -change as A substring
- Player - Player 12 (Brown) types a chat message containing -change as A substring
- Conditions
- Multiple ConditionsOr - Any (Conditions) are true
- Conditions
- (Entered chat string) Equal to (==) -change list
- (Substring((Entered chat string), 1, 8)) Equal to (==) -change
- Conditions
- Multiple ConditionsOr - Any (Conditions) are true
- Actions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Entered chat string) Equal to (==) -change list
- Then - Actions
- Set TempString = Currently Available Heroes:
- Do Multiple ActionsFor each (Integer A) from 1 to 20, do (Actions)
- Loop - Actions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- sysRecognizedName[(Integer A)] Not equal to (!=) Empty String
- Then - Actions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- sysIsHeroUsed[(Integer A)] Equal to (==) True
- Then - Actions
- Set TempString = (TempString + (|c00FF0000, + (sysRecognizedName[(Integer A)] + |r)))
- Else - Actions
- Set TempString = (TempString + (|c00FF0000,|r|c0000FF00 + (sysRecognizedName[(Integer A)] + |r)))
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from 1 to 20, do (Actions)
- Game - Display to (All players) for 60.00 seconds the text: TempString
- Skip remaining actions
- Set TempString = Currently Available Heroes:
- Else - Actions
- If - Conditions
- Set TempString = (Substring((Entered chat string), 9, (Length of (Entered chat string))))
- Cinematic - Clear the screen of text messages for (All players)
- Do Multiple ActionsFor each (Integer A) from 1 to 20, do (Actions)
- Loop - Actions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- TempString Equal to (==) sysRecognizedName[(Integer A)]
- Then - Actions
- Set sysIsHeroUsed[(Integer A)] = True
- Unit Group - Pick every unit in ModifyingGroup and do (Actions)
- Loop - Actions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Owner of (Picked unit)) Equal to (==) (Triggering player)
- Then - Actions
- Set TempUnit = (Picked unit)
- Else - Actions
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Do Multiple ActionsFor each (Integer B) from 1 to 20, do (Actions)
- Loop - Actions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- sysChoosableHeroes[(Integer B)] Equal to (==) (Unit-type of TempUnit)
- Then - Actions
- Set sysIsHeroUsed[(Integer B)] = False
- Else - Actions
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- Loop - Actions
- Set TempPoint = (Center of (Playable map area))
- Unit - Create 1 sysChoosableHeroes[(Integer A)] for Neutral Hostile at TempPoint facing TempPoint
- Custom script: call ReplaceUnitHeroData(udg_TempUnit,bj_lastCreatedUnit)
- Custom script: call RemoveLocation(udg_TempPoint)
- Game - Display to (All players) for 35.00 seconds the text: You have changed yo...
- Else - Actions
- If - Conditions
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- Do Multiple ActionsFor each (Integer A) from 1 to 20, do (Actions)
- Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Events
This function is here because I couldn't figure out how to do the local heroData part without having it be a local. -Shrug-
JASS:
function ReplaceUnitHeroData takes unit u, unit r returns unit
local heroData data = GetUnitUserData(u)
//call data.RefreshSystemOdd() - Vain attempts to prevent this bug
return data.ReplaceUnit(u,r)
endfunction
JASS:
//method RefreshSystemOdd takes nothing returns nothing
//call this.PlayerModifyStuff(this.u,"-c 1 0")
//call this.FixHero()
//endmethod
//First unit is the one that's being changed, second one will new+be cleaned up within
method ReplaceUnit takes unit u, unit r returns unit
local location Loc = GetUnitLoc(u)
local player p = GetOwningPlayer(u)
local integer i = GetUnitUserData(u)
local integer z=GetUnitTypeId(r)
call RemoveUnit(u)
set this.u = CreateUnit(p,z,GetLocationX(Loc),GetLocationY(Loc),270)
call SetUnitUserData(this.u,i)
call RemoveUnit(r)
call PauseUnit(this.u,true)
call this.FixHero()
//call this.PlayerModifyStuff(this.u,"-c 1 0")
return this.u
endmethod
I'll understand if no one responds. It's big, can be done better, and sloppy in spots.
Thanks to anyone who helps.
Also, attaching map xD
This has been bugging me for hours.
Edit: Figured it out. Some pointers for the future would be nice though!