Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 5 - Modders Workshop > Thread: Scripting prob
Thread: Scripting prob
Kronos1000
Kronos1000


Promising
Supreme Hero
Fryslân Boppe
posted November 21, 2006 09:40 PM

Scripting prob

Please let me know what's wrong with this script:
Quote:
function Day2()
if GetDate(DAY) == 2 then
MessageBox("Maps/SingleMissions/The Return Of Sandro/Day2.txt")
end

Trigger(NEW_DAY_TRIGGER, Day2());


The path is right, but when I use it all of my other scripts crash!
Please tell me what's wrong?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
meows
meows

Tavern Dweller
posted November 22, 2006 10:30 AM

Quote:
Please let me know what's wrong with this script:
Quote:
function Day2()
if GetDate(DAY) == 2 then
MessageBox("Maps/SingleMissions/The Return Of Sandro/Day2.txt")
end

Trigger(NEW_DAY_TRIGGER, Day2());


The path is right, but when I use it all of my other scripts crash!
Please tell me what's wrong?

function NewDayTrigger()
if GetDate(DAY) == 3 then
SetRegionBlocked("blockgodric", false, PLAYER_3);
SetRegionBlocked("blockOrson", false, PLAYER_1);
MessageBox("Maps/SingleMissions/a test2/firs.txt");
end;
if GetDate(DAY) == 3 then
AddHeroCreatures("Straker", 38, 5);
end;
end;

Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");

above is a working example.. for yours try
function Day2()
if GetDate(DAY) == 2 then
MessageBox("Maps/SingleMissions/The Return Of Sandro/Day2.txt")
end

Trigger(NEW_DAY_TRIGGER, "Day2");
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Kronos1000
Kronos1000


Promising
Supreme Hero
Fryslân Boppe
posted November 24, 2006 04:18 PM
Edited by Kronos1000 at 17:20, 25 Nov 2006.

It does not work either this is my complete script:

Quote:
Edit: Script removed


Mabey someone can see what's wrong with is.

Edit: Solved the problem

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Kronos1000
Kronos1000


Promising
Supreme Hero
Fryslân Boppe
posted November 30, 2006 07:44 PM
Edited by Kronos1000 at 19:44, 30 Nov 2006.

No it didn't work because I only used one end instead of 2 lol

My map is almost finished now, it's a single player map about Sandro with working scripts of course Pics coming soon.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Kronos1000
Kronos1000


Promising
Supreme Hero
Fryslân Boppe
posted December 02, 2006 09:44 AM
Edited by Kronos1000 at 09:04, 03 Dec 2006.

I have a new problem now what's wrong with this:

Quote:
function Inferno_1(PLAYER_8, PLAYER_3, heroname, townname)
 MessageBox("Maps/SingleMissions/The Return Of Sandro/Capt_INF.txt");
 SetObjectiveState("KillAgrael", "OBJECTIVE_ACTIVE", "playerID = PLAYER_3");
     Trigger(OBJECT_CAPTURE_TRIGGER, "Inf_1", nil);
  end;

Trigger(OBJECT_CAPTURE_TRIGGER, "Inf_1", "Inferno_1");


and this:

Quote:
function KillCyrus(Tan)
LevelUpHero("Aberrar");
MessageBox("Maps/SingleMissions/The Return Of Sandro/Death.txt")
   Trigger(PLAYER_REMOVE_HERO_TRIGGER, "PLAYER_5", nil);
end;

Trigger(PLAYER_REMOVE_HERO_TRIGGER, "PLAYER_5", "KillCyrus");


Another example:

Quote:
function KillAgrael(Agrael)
LevelUpHero("Aberrar");
MessageBox("Maps/SingleMissions/The Return Of Sandro/Inferno.txt")
   Trigger(PLAYER_REMOVE_HERO_TRIGGER, "PLAYER_8", nil);
end;

Trigger(PLAYER_REMOVE_HERO_TRIGGER, "PLAYER_8", "KillAgrael");


EDIT: The terrain of the map is finished but this 3 scripts don't work, when they work I'll release the map.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
sfidanza
sfidanza


Promising
Supreme Hero
posted December 03, 2006 11:52 PM

There are some obvious mistakes in your scripts, like using constants for variables and such. I'll just give you some quick notes here as I don't have much time.

Let's take your third function (KillAgrael). The second one (KillCyrus) would work the same way.
First, when you associate the trigger to you handler, PLAYER_8 is the actual integer constant, not a string:
----------------
Trigger(PLAYER_REMOVE_HERO_TRIGGER, PLAYER_8, "KillAgrael");
----------------
Then, your function should have two arguments, as explained in Nival's script functions reference pdf:
- the name of the lost hero (for example: heroname)
- the name of the hero that killed him - nil if fired (killername)
So what you want to do is this:
----------------
function KillAgrael(heroname, killername)
if heroname == "Agrael" then
LevelUpHero("Aberrar");
MessageBox("Maps/SingleMissions/The Return Of Sandro/Inferno.txt")
Trigger(PLAYER_REMOVE_HERO_TRIGGER, PLAYER_8, nil);
end;
end;
----------------
And you can even check who killed Agrael if you wish.

With the same principles in mind, your example 1 should be like:
----------------
function Inferno_1(oldowner, newowner, heroname, townname)
if oldowner == PLAYER_8 and newowner == PLAYER_3 then
MessageBox("Maps/SingleMissions/The Return Of Sandro/Capt_INF.txt");
SetObjectiveState("KillAgrael", OBJECTIVE_ACTIVE, PLAYER_3);
Trigger(OBJECT_CAPTURE_TRIGGER, "Inf_1", nil);
end;
end;

Trigger(OBJECT_CAPTURE_TRIGGER, "Inf_1", "Inferno_1");
----------------
Note the changes in SetObjectiveState().

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Kronos1000
Kronos1000


Promising
Supreme Hero
Fryslân Boppe
posted December 04, 2006 03:55 PM
Edited by Kronos1000 at 18:57, 04 Dec 2006.

Thank you! I'll try to get it to work and if it works I'll realease my map today

EDIT: My map is finished and I couldn't find any bugs here it is: The Return of Sandro.zip

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0290 seconds