View Full Version: The IVAN script challenge

ivan >>Programming >>The IVAN script challenge


<< Prev | Next >>

holybanana- 09-05-2006
The IVAN script challenge
Comrades, I greet you in the name of IvanDev, the One True Socialist Game Development Party. I present you a challenge. Solve a series of script exercises of my script lectures, starting from lecture II, at http://ivan.sourceforge.net/script and you shall be my superior for one six hour coding day. You may order me to code whatever you like in IVAN. The challenge starts September 6th at 0:00 in my time zone (GMT+2) when I will post lecture V and its exercise(s). The purpose of this challenge is to spark interest in IVAN scripting. The exact rules of the game: I. A participant must post the answers to all exercises of lectures II-V in this topic. II. I will not comment whether they are right or wrong until someone gets all correct. III. When someone does this, I will reply "X is Marx.", where X is the winner. This is because only Marx can command the Party Chairman. IV. If no one qualifies as Marx within four weeks, the game expires. I'm not going to wait years for your answers. V. Marx composes a list of tasks which I try to complete. The list consists of at most ten entries. VI. I will choose a day when I have six hours free time, or possibly two with three hours, if I'm busy. VII. I only code. If the tasks require new graphics, I'm not going to draw them. I may order Juhani Kahvi to do this, but you know that in socialist systems things do not happen that simply. In reality, he may or may not complete the tasks in time, even though officially he naturally always does. If Marx himself or someone else can supply the graphics, there's no problem of course. VIII. I choose the order which I complete the tasks in Marx's list. IX. I must code for at least six hours in total. X. If I cannot complete all tasks in time, I still have to present an unofficial development version to Marx which compiles, doesn't immediately crash and contains all the work I have completed. XI. If I do complete all tasks, I will correct bugs and such the rest of the time. XII. After that, Marx praises me with words "A True Communist art thou, holybanana! May the Party achieve great glory under thy command!" XIII. Marx is now a common mortal again and I am the boss. XIV. This means I can remove any of the features I have coded, for instance if Marx has ordered me to code a striptease AI for Raxy. XV. Otherwise the features will be present in the next official version. XVI. Note that there is one coding exercise in the appendix of lecture II. This one is optional, since some people have no programming experience. But if the winner doesn't solve it, he will only be called Engels and can command me for but five hours. Here's the current list of exercises, details are found in the lectures: Lecture II: Adding a hostile Sherarax to New Attnam and beating her with custom equipment only. Appendix of lecture II, the coding exercise: Summoning a holy banana from the wait command. Lecture III: Finding out which script commands order the generation of certain potions. Lecture IV, exercise I: Adding a random amount of bananas to the player inventory at the start of the game. The amount must obey certain rules. Lecture IV, exercise II: Is there any way to have an item appear one time in ten thousand games in a specific place, using just the script? Lecture V will add either one or two tasks. Freelance Berzerker has already completed the first task. He is not required to do it again, but others are still obliged to complete it. Edit: I now added lecture V: Adding materials. The race is now on. I also taught you an important lesson about socialist systems: Deadlines are always met in them. The final exercise is to add an ommel nut flesh material. An easy task.

blob- 09-05-2006

hahaha ! This is such a damn good idea! Its evil. I was far too lazy to start coding in the same as my training course as drawing for ivan already takes 100% of my freetime but i ll look that this evening. Even though i dont even understand what i have to do for some of the exercises >_> Man, there's so funny stuff that could be added for ivan huhuhu...

Battleguy01- 09-05-2006

Does anyone know any good programs for taking screenshots?

blob- 09-05-2006

snapshot. free and good. edit: why do you post that here ?!

Battleguy01- 09-05-2006

Because i need to take a pic of me killing raxy. and how do i get it to show on the page?

Somagu- 09-05-2006

Just use the print screen button, go into MS Paint, save it as a PNG, then host it on imageshack, and use the "Img" tags to directly link to the image.

Freelance Berzerker- 09-06-2006

I've been out for a couple days. This sounds so cool. HB, as usual, is performing a great service for all IVANers.

Freelance Berzerker- 09-07-2006
Response to Questions for IVAN Script Lecture III
Exercise: randomly generated orc slaughterers may carry potions of troll blood. Find out in which file this detail is defined. Present the line. The file for this detail is in char.dat. Specifically, in the last line of the following code: Config SLAUGHTERER; { TorsoBitmapPos = 48, 48; AttributeBonus = 20; Helmet = BRONZE helmet; BodyArmor = BRONZE bodyarmor(CHAIN_MAIL); RightWielded = IRON meleeweapon(AXE); LeftWielded = IRON meleeweapon(AXE); CWeaponSkillHits == 100; RightSWeaponSkillHits = 50; LeftSWeaponSkillHits = 50; NameSingular = "orc slaughterer"; PanicLevel = 40; Inventory == potion { SecondaryMaterial = TROLL_BLOOD; Chance = 10; } } Then find out where it is defined that the orc general and the orc officers in the orc room of GC have some more expensive potions in their inventory. Present the lines. This detail is contained in dungeon.dat under “Types” in the following code: RandomLevel 6:10; { Room { Size = 9,7; AltarPossible = false; GenerateFountains = false; Shape = ROUND_CORNERS; CharacterMap { Pos = 1,1; Size = 7,5; Types { G = orc(GENERAL) { Inventory = { 2, Random { MinPrice = 100; Category = POTION; Times = 4; }, Random { MinPrice = 200; Category = POTION; Times = 2; } } } O = orc(OFFICER) { Inventory == Random { MinPrice = 100; Category = POTION; Times = 2; } } S = orc(SQUAD_LEADER); s = orc(SLAUGHTERER); o = orc; } } { .ooooo. osSOSso ossGsso osSOSso .ooooo. } } }

Freelance Berzerker- 09-07-2006
Response to Questions for IVAN Script Lecture IV
Exercise: Suppose the player's bananagrower friends give him a farewell gift at the start of each journey. That is, a random amount of bananas is generated at the start of the game in the player's inventory. One banana is always generated. Five to six bananas are most common. The maximum of ten bananas is generated only rarely. Bananagrowers are generous to their friends but ten is already a bit too much, as they have to feed their children. How do you implement this feature using just the script? I would modify the equipment as follows: playerkind { DefaultArmStrength = 10; DefaultLegStrength = 10; DefaultDexterity = 10; DefaultAgility = 10; DefaultEndurance = 10; DefaultPerception = 10; DefaultIntelligence = 10; DefaultWisdom = 10; DefaultCharisma = 10; DefaultMana = 10; DefaultMoney = 45; TorsoBitmapPos = 32, 416; LegBitmapPos = 0, 416; TotalVolume = 80000; TotalSize = 175; CanRead = true; NameSingular = "human"; AttachedGod = SEGES; DisplacePriority = 2; Inventory = { 10, banana {Chance = 100;} banana {Chance = 80;} banana {Chance = 70;} banana {Chance = 70;} banana {Chance = 70;} banana {Chance = 70;} banana {Chance = 5;} banana {Chance = 5;} banana {Chance = 5;} banana {Chance = 5; } } } Exercise II: Is there any way to have an item appear one time in ten thousand games in a specific place, using just the script? Answer yes or no. If you answered yes, present an example. No. This would require something just in the script which logs the number of games played, which the coder could then use to insert an item which would appear once every 10,000 times in a specific place. Currently, I see no such entry in the script.

Freelance Berzerker- 09-07-2006
Response to Questions for IVAN Script Lecture V
Exercise: Create an ommel nut flesh material, which spoils slowly and radiates bright yellow light. Make it so that golems can be generated of this material but it cannot be wished nor mirrored. It belongs to Nefas. Let it have the same effect and messages as ommel urine, but the effect is stronger. Let its natural form be a nut. Present the config definition. First, I inserted OMMEL_NUT into define.dat as follows: #define ORGANIC_ID (4096 * 2) #define BANANA_FLESH (ORGANIC_ID + 1) #define SCHOOL_FOOD (ORGANIC_ID + 2) #define BANANA_PEEL (ORGANIC_ID + 3) #define KIWI_FLESH (ORGANIC_ID + 4) #define PINEAPPLE_FLESH (ORGANIC_ID + 5) #define PLANT_FIBER (ORGANIC_ID + 6) #define MUTANT_PLANT_FIBER (ORGANIC_ID + 7) #define BONE (ORGANIC_ID + 8) #define BREAD (ORGANIC_ID + 9) #define HOLY_BANANA_FLESH (ORGANIC_ID + 10) #define CARROT_FLESH (ORGANIC_ID + 11) #define OMMEL_CERUMEN (ORGANIC_ID + 12) #define OMMEL_BONE (ORGANIC_ID + 13) #define OMMEL_TOOTH (ORGANIC_ID + 14) #define OMMEL_NUT (ORGANIC_ID +15) Next, I added OMMEL_NUT to material.dat: Config OMMEL_NUT; { StrengthValue = 2; Density = 5000; ConsumeType = CT_MISC_ORGANIC; Color = rgb16(0, 230, 0); Emitation = rgb24(140, 140, 100); NutritionValue = 1000; PriceModifier = 5000; NameStem = "ommel nut"; ConsumeEndMessage = CEM_OMMEL; HitMessage = HM_OMMEL; Alpha = 150; SpoilModifier = 500000; AttachedGod = NEFAS; NaturalForm = nut; IntelligenceRequirement = 5; Effect = EFFECT_OMMEL_URINE; ConsumeEndMessage = CEM_OMMEL_BONE; BodyFlags = Base|IS_WARM; InteractionFlags = Base|EFFECT_IS_GOOD; NameFlags = Base|USE_AN; CategoryFlags = Base|IS_SPARKLING|IS_GOLEM_MATERIAL; CommonFlags = Base&~CAN_BE_MIRRORED&~CAN_BE_WISHED; } }

Battleguy01- 09-07-2006

Nice one, hope you get it.

Freelance Berzerker- 09-07-2006

Heh, we'll see. Since HB, isn't responding unless the code is absolutely correct, I won't know if I'm right or wrong for a couple weeks. I've test-played the game each time I added code to see if the game would crash, and haven't had any errors crop up yet. But I'm also pretty new at this. In fact, completely new at this... Now, back to my regular work :(

mistifilio- 09-07-2006

Freelance, A couple of detail errors I can see. :D in your answer to #5, you post your changed define.dat as well as the config. The challenge only asks for the config so I don't know if HB would hold it against you, but the space between the "+" and "15" is probably important. #define OMMEL_NUT (ORGANIC_ID + 15) Rather than #define OMMEL_NUT (ORGANIC_ID +15) Also in you answer to #4a, you need a comma between each banana, Chance = 100 is redundant, and esthetically match the spacing of other script elements there should be a space after "{" and before "}". Inventory = { 10, banana, banana { Chance = 80; }, banana { Chance = 70; }, banana { Chance = 70; }, banana { Chance = 70; }, banana { Chance = 70; }, banana { Chance = 5; }, banana { Chance = 5; }, banana { Chance = 5; }, banana { Chance = 5; } } Rather than Inventory = { 10, banana {Chance = 100;} banana {Chance = 80;} banana {Chance = 70;} banana {Chance = 70;} banana {Chance = 70;} banana {Chance = 70;} banana {Chance = 5;} banana {Chance = 5;} banana {Chance = 5;} banana {Chance = 5; } } Also your probabilities make an average of 4.8 bananas which make the most common occurances 4 and 5 rather than 5 and 6 as the assignment dictates. Using a simple binomial distribution would create 5.5 bananas on average with 2 and 10 being the least common and might be more elegant like so: Inventory = { 2, banana, banana { Times = 9; Chance = 50; } } My answer to #4 II would have to be maybe. It would depend on what HB actually meant with the phrasean item appear one time in ten thousand games in a specific place If "an item" rules out things inside containers because the contain would be one item and the contents would also be one item and thus would constitute 2 items, then my answer would be no. If, however, containers are not ruled out then my answer would be yes. Item == itemcontainer(LARGE_CHEST) { Chance = 1; itemsinside == ADAMANT OCTIRON meleeweapon(PICK_AXE) { Chance = 1; } } Inside an ItemMap config such as the temple or a shop, or possibly on top of a specific terrain square that has to appear such as UT1 stairs down. Should generate a Large Chest 1 in 100 games and an Adamant Pickaxe with Octiron handle (assuming PICK_AXE is defined meleeweapon config...I haven't looked at how pickaxes are actually defined.) inside 1 in 100 of those chests so it should generate the pickaxe in 1 of 10,000 games.

mistifilio- 09-07-2006

Freelance, Also for #5 you need to add an EffectStrength value to satisfy the "make the effect stronger" qualification. :D Misti

Z- 09-07-2006

Freelance, A couple of detail errors I can see. :D in your answer to #5, you post your changed define.dat as well as the config. The challenge only asks for the config so I don't know if HB would hold it against you, but the space between the "+" and "15" is probably important. #define OMMEL_NUT (ORGANIC_ID + 15) Rather than #define OMMEL_NUT (ORGANIC_ID +15) This is only a guess (I did not try it, I only talk from my general experience with scripts and programming languages), but I think spacing (and also usually where the lines end) is not important, and the compiler/interpreter will not care about it. Parentheses, commas and other symbols are important. However, if the script is also to be read by humans, then it is good to follow a specific style. (Side note 1. However, if there were no parentheses, then it could lead to bugs in C, although the compiler would not complain about it --- for example, OMMEL_NUT*5 would evaluate to ORGANIC_ID +15*5, which is ORGANIC_ID+75 not (ORGANIC_ID+15)*5) (Side note 2. I wonder why the GoogleAds has given us ads about Jesus for this topic)

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.