Day to Day scripts.

Maps and the art of mapmaking.
GohozoqPohobo
Leprechaun
Leprechaun
Posts: 26
Joined: 30 Sep 2007

Day to Day scripts.

Unread postby GohozoqPohobo » 21 Nov 2007, 01:28

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?
Last edited by GohozoqPohobo on 22 Nov 2007, 06:44, edited 1 time in total.

User avatar
vulnevia
Blood Fury
Blood Fury
Posts: 493
Joined: 06 Jan 2006
Location: sweden

Unread postby vulnevia » 21 Nov 2007, 08:15

HoMM 1-5?

GohozoqPohobo
Leprechaun
Leprechaun
Posts: 26
Joined: 30 Sep 2007

Unread postby GohozoqPohobo » 22 Nov 2007, 02:09

Sorry.
I always take it to granted that everyone's going to be playing heroes 5.

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1848
Joined: 22 Nov 2005

Unread postby Pitsu » 22 Nov 2007, 17:33

GohozoqPohobo wrote:Sorry.
I always take it to granted that everyone's going to be playing heroes 5.
That is definately not granted. Although if one has problems with editor, the most logic game version would be H5 ...

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

GohozoqPohobo
Leprechaun
Leprechaun
Posts: 26
Joined: 30 Sep 2007

Unread postby GohozoqPohobo » 22 Nov 2007, 17:56

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");

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1848
Joined: 22 Nov 2005

Unread postby Pitsu » 22 Nov 2007, 18:30

GohozoqPohobo wrote:What I meant was
"What if it happens each level?"
Separate case
"What if it happens each day?"
Trigger(HERO_LEVELUP_TRIGGER, heroname, funcname)
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;

EDIT: By the way, it seems to follow http://www.celestialheavens.com/forums/ ... php?t=7593. I suggest next time not to make a new topic when continuing an old theme. No offence, but just you to know...
Avatar image credit: N Lüdimois

GohozoqPohobo
Leprechaun
Leprechaun
Posts: 26
Joined: 30 Sep 2007

Unread postby GohozoqPohobo » 24 Nov 2007, 19:33

Sorry, Pitsu, I thought it was sufficiently different.
I'll be more mindful in the future.

GohozoqPohobo
Leprechaun
Leprechaun
Posts: 26
Joined: 30 Sep 2007

Unread postby GohozoqPohobo » 29 Dec 2007, 06:50

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.

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 31 Dec 2007, 17:13

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.
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.

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."

GohozoqPohobo
Leprechaun
Leprechaun
Posts: 26
Joined: 30 Sep 2007

Unread postby GohozoqPohobo » 01 Jan 2008, 05:01

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.

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 11 Jan 2008, 09:56

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
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."


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 2 guests