Help on Starting Resources Scripting

Maps and the art of mapmaking.
Zepdog
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Feb 2007

Help on Starting Resources Scripting

Unread postby Zepdog » 22 Feb 2007, 23:59

No matter what I do I can't get the scripting to work.

One of the things I'm trying to do is set the starting resources for a map.
I type in: SetPlayerStartResources( PLAYER_1toPLAYER7, WOOD_#, ORE_#, MERCURY_#, CRYSTAL_#, SULFER_#, GEM_#, GOLD_#)

I even tried to do it per player and it still didn't work. Am I forgetting something, or am I just on the complete wrong path.

On another note, I have a problem with the Haven computer(only one so far) going into a Neutral garrison and taking the monsters out and putting them into his army. Even though it is Neutral I do have the garrison set to not allow the monsters to be removed.

Anyway, any help would be greatly appreciated.

Thanks.

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 23 Feb 2007, 20:28

here is the commands i use in a map for starting resources

SetPlayerResource(PLAYER_#, WOOD, #);
SetPlayerResource(PLAYER_#, ORE, #);
SetPlayerResource(PLAYER_#, MERCURY, #);
SetPlayerResource(PLAYER_#, GEM, #);
SetPlayerResource(PLAYER_#, CRYSTAL, #);
SetPlayerResource(PLAYER_#, SULFUR, #);
gold can be set too, just use GOLD.

as for your second problem with the garrison, sounds like a bug of some sort ive never encountered. perhaps delete the garrison and replace a new one and see if the bug re occurs and make sure it is set to neutral player.

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

Re: Help on Starting Resources Scripting

Unread postby Grumpy Old Wizard » 24 Feb 2007, 00:29

Zepdog wrote: On another note, I have a problem with the Haven computer(only one so far) going into a Neutral garrison and taking the monsters out and putting them into his army. Even though it is Neutral I do have the garrison set to not allow the monsters to be removed.
Are you sure that he is taking them out and not using diplomacy to get some to join?

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

King Imp
Swordsman
Swordsman
Posts: 570
Joined: 06 Jan 2006

Unread postby King Imp » 24 Feb 2007, 19:27

myythryyn wrote: here is the commands i use in a map for starting resources

SetPlayerResource(PLAYER_#, WOOD, #);
SetPlayerResource(PLAYER_#, ORE, #);
SetPlayerResource(PLAYER_#, MERCURY, #);
SetPlayerResource(PLAYER_#, GEM, #);
SetPlayerResource(PLAYER_#, CRYSTAL, #);
SetPlayerResource(PLAYER_#, SULFUR, #);
gold can be set too, just use GOLD.


Does this script work for giving extra resources on top of what you normally start with or do you just start with the amounts you indicate in the script?

I want to set it up where storyline-wise, the faction's "elders" give a bonus to help you in dealing with the upcoming war, but I'm not sure how it's done in this game. This was so much easier in H3 & H4.

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 24 Feb 2007, 19:53

to add a bonus to an existing number of resources, you need to do this

local current; -- first declare the local variable

current1 = GetPlayerResource(PLAYER_# WOOD); -- this gets the current resource amount, wood in this case

SetPlayerResource(PLAYER_#, WOOD, current1 + 10); -- then this adds +10 to the current total, and sets the players wood resources to that total.

you can also use the above scripts to take resources from a player, just put current - 10. (or whatever number you choose)

oh, and youll have to add a check in to make sure the players total is over the amount you are reducing it by, because you dont want a negative total to happen.

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 » 24 Feb 2007, 20:00

This is how I added resources to the computer, based on difficulty, in my Seize the Throne map. There are over 1100 lines of scripting in it and it is heavily commented so it may help you to look at it if you are just learning scripting. Also Pitsu made a scripting tutorial stickied at the top of the forum.

--determine difficulty level: easy(1), normal(2), hard(3) or heroic(4)

if GetPlayerResource (whoishuman, GOLD) <=12000 then
difficultylevel = 4;
elseif GetPlayerResource (whoishuman, GOLD) <= 22000 then
difficultylevel = 3;
elseif GetPlayerResource (whoishuman, GOLD) <= 32000 then
difficultylevel = 2;
else difficultylevel = 1;
end;

--computer starting bonuses based on difficulty level:computer takes few mines/resource pockets
for i = 1, 6, 1 do --do for each computer player
if i ~= whoishuman then --don't do for human
for j = 0, 5, 1 do --do for each resource

resource = GetPlayerResource(i, j) + 10*difficultylevel;--give resource bonus
if ((j == 0) or (j == 1)) then --give more ore/wood
resource = resource + 40;
end;
SetPlayerResource(i, j, resource);
end;
goldbonus = GetPlayerResource(i, 6) + 10000*difficultylevel;--give gold bonus
SetPlayerResource(i, 6, goldbonus);
end;
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."

User avatar
jeff
Moderator
Moderator
Posts: 3741
Joined: 06 Jan 2006

Unread postby jeff » 24 Feb 2007, 20:24

You know everytime I read about people having this type of difficulty, it just reinforces my belief that I could never spend enough time to learn such a complicated editor, too bad I really wanted to do maps for Heroes V, oh well maybe H-VI. :cry:
Mala Ipsa Nova :bugsquash:

Silence
Peasant
Peasant
Posts: 83
Joined: 29 Jan 2006

Unread postby Silence » 24 Feb 2007, 20:57

Grumpy Old Wizard wrote:

--determine difficulty level: easy(1), normal(2), hard(3) or heroic(4)

if GetPlayerResource (whoishuman, GOLD) <=12000 then
difficultylevel = 4;
elseif GetPlayerResource (whoishuman, GOLD) <= 22000 then
difficultylevel = 3;
elseif GetPlayerResource (whoishuman, GOLD) <= 32000 then
difficultylevel = 2;
else difficultylevel = 1;
end;
Why not to use difficultylevel = GetDifficulty(); ?

King Imp
Swordsman
Swordsman
Posts: 570
Joined: 06 Jan 2006

Unread postby King Imp » 24 Feb 2007, 21:36

jeff wrote: You know everytime I read about people having this type of difficulty, it just reinforces my belief that I could never spend enough time to learn such a complicated editor, too bad I really wanted to do maps for Heroes V, oh well maybe H-VI. :cry:


This is why I can't be bothered to put scripts in and why most feel that Nival doesn't "get it."

You basically have to understand programming to know how to do this stuff. Why should we have to rely on tutorials on how to do basic things that took 1 or 2 simple steps in previous games?

User avatar
jeff
Moderator
Moderator
Posts: 3741
Joined: 06 Jan 2006

Unread postby jeff » 24 Feb 2007, 22:18

King Imp wrote: This is why I can't be bothered to put scripts in and why most feel that Nival doesn't "get it."

You basically have to understand programming to know how to do this stuff. Why should we have to rely on tutorials on how to do basic things that took 1 or 2 simple steps in previous games?
You said it in one, a lot of the capabilities we wished for in H- IV are now present, but the interface has taken a giant step back to the computer dark ages. If Nival doesn't get it soon, then hopefully UBI will say good bye to them. :mad:
Mala Ipsa Nova :bugsquash:

Zepdog
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Feb 2007

Unread postby Zepdog » 24 Feb 2007, 23:19

Thanks for all the feedback everyone.

Myythryyn, Your script didn't work. I even made sure that I had the resources in the same order as you. I also tried to use the SetPlayerStartResources and that didn't work. Also it didn't let me just "save" the map after I was done, I had to use "save as". But I did notice that I could save regularly if I didn't use ";" after the last script (I guess that tells you I don't know what I'm doing, lol). When I went to check the script at the bottom it said that the script was fine. Maybe I should make it clear on the starting resources, as it might not be possible or have to go a different route. I want to start the map with a fixed amount for all players (both human and computer) no matter what the difficulty setting. And the starting resources are less than all of the difficulty settings give you. This map is really about strong wandering monsters. Maybe I should have the resouces taken away at the beginning of the first day, if it is possible, that might be easier.

Man the previous games were alot easier to do this kind of stuff. I feel like I need to goto school just to learn scripting. Maybe I'll just get a job at NASA, it would be easier (lol).

Grumpy O.W., the computer is getting "all" of the poenix in the garrison, then he goes to the next one and does it again for a total of 10. He is only a level 3 hero but has a huge force (this resource problem helps him get too big of a force so he can do that). And it is the Knight that is doing it. Is there any way to make the garrisoned creatures not be swayed by the Heroes? I'll also look at your script notes, but that will take some time to understand what I'm doing. Yours are way more complicated. They just don't make things easy anymore do they!

Thanks again for all your help everyone.
Last edited by Zepdog on 24 Feb 2007, 23:31, edited 1 time in total.

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 » 24 Feb 2007, 23:23

Silence wrote:
Grumpy Old Wizard wrote:

--determine difficulty level: easy(1), normal(2), hard(3) or heroic(4)

if GetPlayerResource (whoishuman, GOLD) <=12000 then
difficultylevel = 4;
elseif GetPlayerResource (whoishuman, GOLD) <= 22000 then
difficultylevel = 3;
elseif GetPlayerResource (whoishuman, GOLD) <= 32000 then
difficultylevel = 2;
else difficultylevel = 1;
end;
Why not to use difficultylevel = GetDifficulty(); ?
Because for whatever reason I couldn't get GetDifficulty to work. Maybe I was just doing it wrong or they fixed it in a patch.
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."

Zepdog
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Feb 2007

Unread postby Zepdog » 25 Feb 2007, 00:10

Grumpy O.W., sorry I edited my post to say something to you after you posted... after it. ?. Hope that made sense.

How will I tell if the script for a computer player is working if I can't see him and what he has? Well, I guess I need to get it working for the human players first though. :D

Myythyyn, I tried to use your SetPlayerResource(PLAYER_#,WOOD,current1-#); but it didn't work. And now the save problem is back again. So the ";" at the end wasn't the problem.

Also, do I need to put "end;" on the last line to let the computer know that the scripting is done? And does there have to be an order to scripting? Oh yeah, this is a multiplayer map.

Thanks again for eveyones help.

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 25 Feb 2007, 00:29

Zepdog wrote:
Also, do I need to put "end;" on the last line to let the computer know that the scripting is done? And does there have to be an order to scripting? Oh yeah, this is a multiplayer map.
bingo.....bang....dead in the water :)

you said the multiplayer word while talking about scripting.

thats a no no.

nival had the great idea of disabling all scripts in multiplayer maps, so scripting is impossible. to be fair to nival, it has been discussed that this is due to the difficutly of networking scripts together, though im not a network specialist so i cant say what the real reason is no scripts are allowed in multiplayer maps.

Zepdog
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Feb 2007

Unread postby Zepdog » 25 Feb 2007, 00:34

Myythryyn, thanks, I'll just save the map under a differnt name and try to put it to single player and see if I can get the scripting down. Hope I can, I would hate to lose the map that is finished (except for scripting).

Thanks again, I'll be back.

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 25 Feb 2007, 00:40

this post discusses how to change a multiplayer map to single player

viewtopic.php?t=4191

as well as gives other good advice, and Pitsu made a document you can read too about scritping

viewtopic.php?t=5430

once you get the hang of it, and have some scripts for yourself, it becomes easy, as you can just copy and paste existing scripts and modify them. i would suggest copy and pasting your scripts and keeping them in a word document.

Zepdog
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Feb 2007

Unread postby Zepdog » 25 Feb 2007, 00:59

Now I can't get the scripting to work in the single player version either. I guess I'll try a new map from scratch, but I'm now having a problem starting a new map. when I make a new map (for testing) and place a couple of castles then try to script I get an error message that says the Editor has encountered a problem and is going to close.

Oh, the problems that my computers give me. :ill:

Thanks. I'll be back tommorrow. I think I'll go and take out my frustration on Call of Duty UO for a while. :devil:

Oh wait, I'll try your link in your last post. but still be back tommorrow.

Again thanks.

Zepdog
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Feb 2007

Unread postby Zepdog » 25 Feb 2007, 23:07

Ok, this is killing me. Instead of trying to change the map to a single player I went ahead and mad a map with 3 castles and 3 players and a Den of Theives. I am using this as my test map for starting resources scripting. It just isn't working! I have tried SetPlayerResources, SetPlayerStartResources, and I have even tried the current1-#. None of these are working. It is driving me crazy! My test map is single player.

Is there suppose to be script to start scripting and something to finish scripting. Can soneone give me all the script I need to just start with one resource changed so I can test it out. From beginning to end.I would really appreciate it.

Thanks again.

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 25 Feb 2007, 23:20

well here is a direct quote from a script i used in a map, copy and paste it at the very beginning of your script. nothing else needed.


SetPlayerResource(PLAYER_1, WOOD, 0);
SetPlayerResource(PLAYER_1, ORE, 0);
SetPlayerResource(PLAYER_1, MERCURY, 0);
SetPlayerResource(PLAYER_1, GEM, 0);
SetPlayerResource(PLAYER_1, CRYSTAL, 0);
SetPlayerResource(PLAYER_1, SULFUR, 0);

i wanted to make a resource restrictive map, so i removed all the players starting resources, you can change them from 0 to whatever you want.
but for your test, this will at least let you know its working.

just make sure that player_1 is the human player, usually red color, and that it is a single player map.
for scripted maps, its imporant that player_1 is the human player anyways, or alot of things dont work.

Zepdog
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Feb 2007

Unread postby Zepdog » 26 Feb 2007, 00:05

Thanks myythryyn, I got it to work so far for player 1. having
end;
end;
on the end didn't work and I didn't have the two spaces after the two commas (i'm assuming) so I put them in this time.

Thanks alot, now I just need to try it on the computer palyers (if it is possible).

It is still odd that when I only change script I have to save-as because save is greyed out.

Thanks again.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 5 guests