I'm having trouble reading the way the triggers work.
Presume I wanted to have a trigger that went off whenever the player's first hero gained a level.
What if I wanted it to happen every day?
Day to Day scripts.
-
- Leprechaun
- Posts: 26
- Joined: 30 Sep 2007
Day to Day scripts.
Last edited by GohozoqPohobo on 22 Nov 2007, 06:44, edited 1 time in total.
-
- Leprechaun
- Posts: 26
- Joined: 30 Sep 2007
That is definately not granted. Although if one has problems with editor, the most logic game version would be H5 ...GohozoqPohobo wrote:Sorry.
I always take it to granted that everyone's going to be playing heroes 5.
Presume I wanted to have a trigger that went off whenever the player's first hero gained a level.
What if I wanted it to happen every day?
This not entirely clear as well. Do you want an event that runs every day (timed event at the start of every day) or do you want an event that runs every time when a certain other event (such as hero level up) occurs? Anyway, if you need something that runs every time human players starting hero levels up then try :
Code: Select all
ourhero = GetPlayerHeroes(PLAYER_1)[0];
function ourheroup()
-- ADD HERE THE COMMANDS THAT HAVE TO EXECUTE WHEN HERO LEVELS UP.
end;
Trigger(HERO_LEVELUP_TRIGGER, ourhero, "ourheroup");
Avatar image credit: N Lüdimois
-
- Leprechaun
- Posts: 26
- Joined: 30 Sep 2007
What I meant was
"What if it happens each level?"
Separate case
"What if it happens each day?"
At any rate, I've almost got it, I think.
What I'm missing is the code inside the function. I don't know how to pass the name of the hero that just leveled up. I want each of the players' main heroes to get this event.
playerOneHero = GetPlayerHeroes(PLAYER_1)[0];
playerTwoHero = GetPlayerHeroes(PLAYER_2)[0];
playerThreeHero = GetPlayerHeroes(PLAYER_3)[0];
playerFourHero = GetPlayerHeroes(PLAYER_4)[0];
playerFiveHero = GetPlayerHeroes(PLAYER_5)[0];
playerSixHero = GetPlayerHeroes(PLAYER_6)[0];
playerSevenHero = GetPlayerHeroes(PLAYER_7)[0];
playerEightHero = GetPlayerHeroes(PLAYER_8)[0];
function ourheroup()
l
eveluphero()
end;
Trigger(HERO_LEVELUP_TRIGGER, playerOneHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerTwoHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerThreeHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerFourHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerFiveHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerSixHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerSevenHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerEightHero, "ourheroup");
"What if it happens each level?"
Separate case
"What if it happens each day?"
At any rate, I've almost got it, I think.
What I'm missing is the code inside the function. I don't know how to pass the name of the hero that just leveled up. I want each of the players' main heroes to get this event.
playerOneHero = GetPlayerHeroes(PLAYER_1)[0];
playerTwoHero = GetPlayerHeroes(PLAYER_2)[0];
playerThreeHero = GetPlayerHeroes(PLAYER_3)[0];
playerFourHero = GetPlayerHeroes(PLAYER_4)[0];
playerFiveHero = GetPlayerHeroes(PLAYER_5)[0];
playerSixHero = GetPlayerHeroes(PLAYER_6)[0];
playerSevenHero = GetPlayerHeroes(PLAYER_7)[0];
playerEightHero = GetPlayerHeroes(PLAYER_8)[0];
function ourheroup()
l
eveluphero()
end;
Trigger(HERO_LEVELUP_TRIGGER, playerOneHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerTwoHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerThreeHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerFourHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerFiveHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerSixHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerSevenHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, playerEightHero, "ourheroup");
Trigger(HERO_LEVELUP_TRIGGER, heroname, funcname)GohozoqPohobo wrote:What I meant was
"What if it happens each level?"
Separate case
"What if it happens each day?"
Trigger(NEW_DAY_TRIGGER, funcname)
but note that there can be only on Trigger(NEW_DAY_TRIGGER, funcname) active at once
What I'm missing is the code inside the function. I don't know how to pass the name of the hero that just leveled up.
function ourheroup()
l
eveluphero()
end;
Add a variable name (e.g. "selectedhero") into parenthesis following the functions name. In commands use this variable instead of heros name. That makes the script to apply to the hero which is currently selected. It assumes that a hero cannot levelup when he is not selected... You can do it in other ways, but these are more complicated
Code: Select all
function ourheroup(selectedhero)
Leveluphero(selectedhero)
end;
Avatar image credit: N Lüdimois
-
- Leprechaun
- Posts: 26
- Joined: 30 Sep 2007
-
- Leprechaun
- Posts: 26
- Joined: 30 Sep 2007
Ok, the code is supposed to, on each day, give specific heroes XP
function powerIncrease ()
ChangeHeroStat(playerOneHero, STAT_EXPERIENCE, GetHeroStat(playerOneHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerTwoHero, STAT_EXPERIENCE, GetHeroStat(playerTwoHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerThreeHero, STAT_EXPERIENCE, GetHeroStat(playerThreeHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerFourHero, STAT_EXPERIENCE, GetHeroStat(playerFourHero, STAT_EXPERIENCE)+3000);
end;
Trigger(NEW_DAY_TRIGGER, "powerIncrease");
I have no idea why nothing happens.
function powerIncrease ()
ChangeHeroStat(playerOneHero, STAT_EXPERIENCE, GetHeroStat(playerOneHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerTwoHero, STAT_EXPERIENCE, GetHeroStat(playerTwoHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerThreeHero, STAT_EXPERIENCE, GetHeroStat(playerThreeHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerFourHero, STAT_EXPERIENCE, GetHeroStat(playerFourHero, STAT_EXPERIENCE)+3000);
end;
Trigger(NEW_DAY_TRIGGER, "powerIncrease");
I have no idea why nothing happens.
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Are playerOneHero, ect global variables? Also, some functions don't like arethemetic done in them so you may need to make the parameter that gives the amount of experience you want to be a variable and to the math outside ChangeHeroStat.GohozoqPohobo wrote:Ok, the code is supposed to, on each day, give specific heroes XP
function powerIncrease ()
ChangeHeroStat(playerOneHero, STAT_EXPERIENCE, GetHeroStat(playerOneHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerTwoHero, STAT_EXPERIENCE, GetHeroStat(playerTwoHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerThreeHero, STAT_EXPERIENCE, GetHeroStat(playerThreeHero, STAT_EXPERIENCE)+3000);
ChangeHeroStat(playerFourHero, STAT_EXPERIENCE, GetHeroStat(playerFourHero, STAT_EXPERIENCE)+3000);
end;
Trigger(NEW_DAY_TRIGGER, "powerIncrease");
I have no idea why nothing happens.
If that doesn't work then post your entire script that shows where you defined the variables and everthing having to do with the function you are trying to get to work.
GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
-
- Leprechaun
- Posts: 26
- Joined: 30 Sep 2007
This is all of it.
playerOneHero = GetPlayerHeroes(PLAYER_1)[0];
playerTwoHero = GetPlayerHeroes(PLAYER_2)[0];
playerThreeHero = GetPlayerHeroes(PLAYER_3)[0];
playerFourHero = GetPlayerHeroes(PLAYER_4)[0];
for i = 1, 6, 1 do --do for player (this assumes eight players)
MakeHeroReturnToTavernAfterDeath(GetPlayerHeroes(i)[0], true, 1 );
end;
function PowerUp ()
if GetCurrentPlayer(void) = 1
GiveExp(playerOneHero, 3000);
end;
if GetCurrentPlayer(void) = 2
GiveExp(playerTwoHero, 3000);
end;
if GetCurrentPlayer(void) = 3
GiveExp(playerThreeHero, 3000);
end;
if GetCurrentPlayer(void) = 4
GiveExp(playerFourHero, 3000);
end;
Trigger(NEW_DAY_TRIGGER, nil);
end;
Trigger(NEW_DAY_TRIGGER, "PowerUp");
It seems like the trigger is wrong.
Any help is appreciated.
playerOneHero = GetPlayerHeroes(PLAYER_1)[0];
playerTwoHero = GetPlayerHeroes(PLAYER_2)[0];
playerThreeHero = GetPlayerHeroes(PLAYER_3)[0];
playerFourHero = GetPlayerHeroes(PLAYER_4)[0];
for i = 1, 6, 1 do --do for player (this assumes eight players)
MakeHeroReturnToTavernAfterDeath(GetPlayerHeroes(i)[0], true, 1 );
end;
function PowerUp ()
if GetCurrentPlayer(void) = 1
GiveExp(playerOneHero, 3000);
end;
if GetCurrentPlayer(void) = 2
GiveExp(playerTwoHero, 3000);
end;
if GetCurrentPlayer(void) = 3
GiveExp(playerThreeHero, 3000);
end;
if GetCurrentPlayer(void) = 4
GiveExp(playerFourHero, 3000);
end;
Trigger(NEW_DAY_TRIGGER, nil);
end;
Trigger(NEW_DAY_TRIGGER, "PowerUp");
It seems like the trigger is wrong.
Any help is appreciated.
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Sorry about the delay in responding. Haven't had a chance to read the forum in a while.
You forgot the "then" part of your conditionals. For example,
function PowerUp ()
if GetCurrentPlayer(void) = 1 then
GiveExp(playerOneHero, 3000);
end;
GOW
You forgot the "then" part of your conditionals. For example,
function PowerUp ()
if GetCurrentPlayer(void) = 1 then
GiveExp(playerOneHero, 3000);
end;
GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Who is online
Users browsing this forum: No registered users and 1 guest