[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-wiki-changes] PseudoRandomNumberGeneration
From: |
wiki |
Subject: |
[Wesnoth-wiki-changes] PseudoRandomNumberGeneration |
Date: |
Mon, 15 Nov 2004 11:05 +0100 |
UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.4
(KHTML, like Gecko) Safari/125.9
IP: 66.189.14.56
URI: http://wesnoth.slack.it/?PseudoRandomNumberGeneration
- - - - -
Index: PseudoRandomNumberGeneration
===================================================================
RCS file: /home/wesnoth/cvsroot/wikiroot/PseudoRandomNumberGeneration,v
retrieving revision 1.12
diff -u -r1.12 PseudoRandomNumberGeneration
--- PseudoRandomNumberGeneration 15 Nov 2004 08:23:06 -0000 1.12
+++ PseudoRandomNumberGeneration 15 Nov 2004 10:05:11 -0000
@@ -177,6 +177,599 @@
Joshbosh321: can you post that multiplayer map that you were using to, I
assume,
playtest this RNG? I played against you once and found the concept very
interesting...
.
+ Elvish Pillager: It's now a four player map.
+ [multiplayer]
+ name= _ "Random Items Map"
+ id=map_of_random_items
+ map_data="gggggggggggggfgggggggggfgfggggggggggg
+ ggggggggggggffggffgggfggggggggggggggg
+ gggggggggggggfggggfgggggggggggggggggg
+ gggnnngggggggggggfggfggggggggggnnnggg
+ gggn1nggggggvggfggggggfgvggggggn2nggg
+ ggggnggggggggggggfggfgggggggggggngggg
+ ggggggggggggfggffggffgggfgggggggggggg
+ ggggggggggggggggggffgffgggggggggggggg
+ gggggggggggfgffggfggggfggfggggggggggg
+ gggggggggggggggfgggfgfgfggggggggggggg
+ ggggggggggvgfffggfggggfgggvgggggggggg
+ ggggggggfgggfggggggggfggfgggfgggggggg
+ gfggvgfggfgggggggggggggggggfggfgvgggf
+ gffggggggfgfgggggggggggggfggggggggffg
+ ggggffgfggggggghhghghhggggggggfgfggfg
+ gggfgfgggfggggggghghgggggggggffggfggg
+ fggfggggffgggghghvhvhghggggfggggfggfg
+ gggggfggfgggghghhhhhhhghggggggggggggg
+ fgfggffgggggghghvhmhvhghggggggfgfgggg
+ gfgfggggggfggggghvhvhgggggggfggfggfgg
+ ggfggggffggggghghhhhhghggggffgfggfgfg
+ fgggfgggggggggghggggghggggfgggfggggfg
+ fggggfggfggggggghghghggggggfgfgfggggg
+ fgfgggfggfggffgggggggggfgfgggfggfgfgg
+ gfggggggfggfggggfggggfggggfgfgggggggf
+ fgfgvgfggggggggggfggfggfggggggfgvgggg
+ ggggggggfggggggggggggggfggggfgggggggg
+ ggggggggggvgfgfgggffggggggvgggggggggg
+ gggggggggggfgggfggfgggfggfggggggggggg
+ ggggggggggggfgfggfgffgggggggggggggggg
+ ggggggggggggggffgggfggfgggggggggggggg
+ ggggggggggggfgggggggfgggfgggggggggggg
+ gggnnnggggggggffggfggggggggggggnnnggg
+ gggn4nggggggvgfgggfgggfgvggggggn3nggg
+ ggggngggggggggfggfggggggggggggggngggg
+ ggggggggggggfgggggggfffgffggggggggggg
+ gggggggggggggfggggfgggfgggggggggggggg"
+
+ {DAWN}
+ {MORNING}
+ {AFTERNOON}
+ {DUSK}
+ {FIRST_WATCH}
+ {SECOND_WATCH}
+
+ turns=24
+ [side]
+ side=1
+ canrecruit=1
+ [/side]
+ [side]
+ side=2
+ canrecruit=1
+ [/side]
+
+ [event]
+ name=start
+ [message]
+ speaker=narrator
+ message= _ "Objects appear randomly on this map. Chests give 20 gold
when grabbed, cages give y ou the unit inside them, and orbs give the
+capturing unit a random trait. Objects which are grabbed r eappear in a random
location on the following turn."
+ [/message]
+ {CLEAR_VARIABLE temp}
+ {CLEAR_VARIABLE units}
+ {CLEAR_VARIABLE temp_factor}
+ {CLEAR_VARIABLE random}
+ {CLEAR_VARIABLE xrand}
+ {CLEAR_VARIABLE i}
+ {CLEAR_VARIABLE temp2}
+ {CLEAR_VARIABLE xloca}
+ {CLEAR_VARIABLE yloca}
+ {CLEAR_VARIABLE xlocb}
+ {CLEAR_VARIABLE ylocb}
+ {CLEAR_VARIABLE xlocc}
+ {CLEAR_VARIABLE ylocc}
+ {CLEAR_VARIABLE xlocd}
+ {CLEAR_VARIABLE ylocd}
+ {CLEAR_VARIABLE xloce}
+ {CLEAR_VARIABLE yloce}
+ {CLEAR_VARIABLE xlocf}
+ {CLEAR_VARIABLE ylocf}
+ {CLEAR_VARIABLE xlocg}
+ {CLEAR_VARIABLE ylocg}
+ {CLEAR_VARIABLE xloch}
+ {CLEAR_VARIABLE yloch}
+ {CLEAR_VARIABLE xloci}
+ {CLEAR_VARIABLE yloci}
+ {CLEAR_VARIABLE xlocj}
+ {CLEAR_VARIABLE ylocj}
+ {CLEAR_VARIABLE xlock}
+ {CLEAR_VARIABLE ylock}
+ {CLEAR_VARIABLE xlocl}
+ {CLEAR_VARIABLE ylocl}
+ {CLEAR_VARIABLE a_exists}
+ {CLEAR_VARIABLE b_exists}
+ {CLEAR_VARIABLE c_exists}
+ {CLEAR_VARIABLE d_exists}
+ {CLEAR_VARIABLE e_exists}
+ {CLEAR_VARIABLE f_exists}
+ {CLEAR_VARIABLE g_exists}
+ {CLEAR_VARIABLE h_exists}
+ {CLEAR_VARIABLE i_exists}
+ {CLEAR_VARIABLE j_exists}
+ {CLEAR_VARIABLE k_exists}
+ {CLEAR_VARIABLE l_exists}
+ {CLEAR_VARIABLE xloc}
+ {CLEAR_VARIABLE yloc}
+ {CLEAR_VARIABLE unit_side}
+ {CLEAR_VARIABLE temprand}
+ [/event]
+
+
################################################################################################
+ ################Pseudo-Random Number Generation Engine For
Multiplayer##########################
+
################################################################################################
+
+ #Don't use this, it's for internal use by other macros
+ #define GETNEXTNUMBER
+
+ #multiplying xrand by 421
+ {VARIABLE i 0}
+ {VARIABLE_OP temp_factor to_variable xrand}
+ [while]
+ [variable]
+ name=i
+ less_than=420
+ [/variable]
+ [do]
+ {VARIABLE_OP xrand add $temp_factor}
+ {VARIABLE_OP i add 1}
+ [/do]
+ [/while]
+
+ {VARIABLE_OP xrand add 2311}
+ [while]
+ [variable]
+ name=xrand
+ greater_than=32767
+ [/variable]
+ [do]
+ {VARIABLE_OP xrand add -32768}
+ [/do]
+ [/while]
+ #enddef
+
+ [event]
+ name=turn 2
+ {VARIABLE xrand 0}
+ [store_unit]
+ [filter]
+ [/filter]
+ variable=units
+ [/store_unit]
+ {FOREACH units i}
+ {VARIABLE_OP temp to_variable units[i].hitpoints}
+ {VARIABLE_OP xrand add $temp}
+ {NEXT i}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {CLEAR_VARIABLE temp}
+ {CLEAR_VARIABLE units}
+ [/event]
+
+ #Instead of {RANDOM 0..155}, use {PSEUDORANDOM 156}. This is the only way to
use it.
+ #You can use {VARIABLE_OP random add X} afterwards to get a higher range.
+ #define PSEUDORANDOM NUMBER
+ {GETNEXTNUMBER}
+ {VARIABLE_OP random to_variable xrand}
+
+ {VARIABLE temp 1024}
+ #{VARIABLE_OP temp multiply {NUMBER}}
+
+ {VARIABLE i 0}
+ {VARIABLE_OP temp_factor to_variable temp}
+ {VARIABLE temp 0}
+ [while]
+ [variable]
+ name=i
+ less_than={NUMBER}
+ [/variable]
+ [do]
+ {VARIABLE_OP temp add $temp_factor}
+ {VARIABLE_OP i add 1}
+ [/do]
+ [/while]
+
+ {VARIABLE_OP temp2 to_variable temp}
+ {VARIABLE_OP temp2 multiply -1}
+ [while]
+ [variable]
+ name=temp
+ less_than=$random
+ [/variable]
+ [do]
+ {VARIABLE_OP random add $temp2}
+ [/do]
+ [/while]
+
+ #{VARIABLE_OP random multiply 0.0078125}
+
+ [while]
+ [or]
+ [variable]
+ name=random
+ greater_than={NUMBER}
+ [/variable]
+ [/or]
+ [or]
+ [variable]
+ name=random
+ equals={NUMBER}
+ [/variable]
+ [/or]
+ [do]
+ {VARIABLE_OP random add -{NUMBER}}
+ [/do]
+ [/while]
+ #enddef
+
+ #define MAP_WIDTH
+ 37
+ #enddef
+ #define MAP_HEIGHT
+ 37
+ #enddef
+
+ #define PLACE ID IMAGE HALO ACTIONS
+ {PSEUDORANDOM {MAP_WIDTH}}
+ {VARIABLE_OP xloc{ID} to_variable random}
+ {VARIABLE_OP xloc{ID} add 1}
+ {PSEUDORANDOM {MAP_HEIGHT}}
+ {VARIABLE_OP yloc{ID} to_variable random}
+ {VARIABLE_OP yloc{ID} add 1}
+ {VARIABLE {ID}_exists yes}
+ [item]
+ x=$xloc{ID}
+ y=$yloc{ID}
+ image={IMAGE}
+ [/item]
+ [item]
+ x=$xloc{ID}
+ y=$yloc{ID}
+ image={HALO}
+ [/item]
+
+ [event]
+ name=moveto
+ [filter]
+ x=$xloc{ID}
+ y=$yloc{ID}
+ [/filter]
+ {CLEAR_VARIABLE {ID}_exists}
+ [store_unit]
+ [filter]
+ x=$xloc{ID}
+ y=$yloc{ID}
+ [/filter]
+ variable=temp
+ [/store_unit]
+ {VARIABLE_OP unit_side to_variable temp.side}
+ {VARIABLE temp.moves 0}
+ [unstore_unit]
+ variable=temp
+ [/unstore_unit]
+ {CLEAR_VARIABLE temp}
+ {VARIABLE_OP xloc to_variable xloc{ID}}
+ {VARIABLE_OP yloc to_variable yloc{ID}}
+ {ACTIONS}
+ [removeitem]
+ x=$xloc{ID}
+ y=$yloc{ID}
+ [/removeitem]
+ [/event]
+ #enddef
+
+ #define HACK_UNIT_DEF1 TYPE
+ {RANDOM_TRAIT_UNIT (
+ x=$xloc
+ y=$yloc
+ type={TYPE}
+ side=$unit_side
+ moves=0
+ )}
+ #enddef
+
+ #define HACK_UNIT_DEF2 TYPE1 TYPE2
+ {RANDOM_TRAIT_UNIT (
+ x=$xloc
+ y=$yloc
+ type={TYPE1} {TYPE2}
+ side=$unit_side
+ moves=0
+ )}
+ #enddef
+
+ #define CREATURE1 ID TYPE IMAGE NUMBER
+ [if]
+ [variable]
+ name=temprand
+ equals={NUMBER}
+ [/variable]
+ [then]
+ {PLACE ({ID}) ({IMAGE}) (misc/cage.png) (
+ {HACK_UNIT_DEF1 {TYPE}}
+ )}
+ [/then]
+ [/if]
+ #enddef
+
+ #define CREATURE2 ID TYPE IMAGE NUMBER
+ [if]
+ [variable]
+ name=temprand
+ equals={NUMBER}
+ [/variable]
+ [then]
+ {PLACE ({ID}) ({IMAGE}) (misc/cage.png) (
+ {HACK_UNIT_DEF2 {TYPE}}
+ )}
+ [/then]
+ [/if]
+ #enddef
+
+ #define STRONG
+ [effect]
+ apply_to=attack
+ range=short
+ increase_damage=1
+ [/effect]
+ [effect]
+ apply_to=hitpoints
+ increase_total=2
+ heal_full=yes
+ [/effect]
+ #enddef
+
+ #define QUICK
+ [effect]
+ apply_to=movement
+ increase=1
+ [/effect]
+ [effect]
+ apply_to=hitpoints
+ increase_total=-10%
+ heal_full=yes
+ [/effect]
+ #enddef
+
+ #define INTELLIGENT
+ [effect]
+ apply_to=max_experience
+ increase=-20%
+ [/effect]
+ #enddef
+
+ #define LOYAL
+ [effect]
+ apply_to=loyal
+ [/effect]
+ #enddef
+
+ #define RESILIENT
+ [effect]
+ apply_to=hitpoints
+ increase_total=7
+ #make sure the unit starts at full health
+ heal_full=yes
+ [/effect]
+ #enddef
+
+ #define TRAIT_IF NUMBER DESC TRAIT1 TRAIT2 STATS
+ [if]
+ [variable]
+ name=random
+ equals={NUMBER}
+ [/variable]
+ [then]
+ [unit]
+ {STATS}
+ traits_description= _ "{DESC}"
+ [modifications]
+ [trait]
+ {TRAIT1}
+ [/trait]
+ [trait]
+ {TRAIT2}
+ [/trait]
+ [/modifications]
+ [/unit]
+ [/then]
+ [/if]
+ #enddef
+
+ #define RANDOM_TRAIT_UNIT STATS
+ {PSEUDORANDOM 10}
+ {TRAIT_IF 0 quick,resilient ({QUICK}) ({RESILIENT}) ({STATS})}
+ {TRAIT_IF 1 strong,resilient ({STRONG}) ({RESILIENT}) ({STATS})}
+ {TRAIT_IF 2 loyal,resilient ({LOYAL}) ({RESILIENT}) ({STATS})}
+ {TRAIT_IF 3 intelligent,resilient ({INTELLIGENT}) ({RESILIENT}) ({STATS})}
+ {TRAIT_IF 4 strong,quick ({STRONG}) ({QUICK}) ({STATS})}
+ {TRAIT_IF 5 strong,intelligent ({STRONG}) ({INTELLIGENT}) ({STATS})}
+ {TRAIT_IF 6 loyal,strong ({LOYAL}) ({STRONG}) ({STATS})}
+ {TRAIT_IF 7 loyal,quick ({LOYAL}) ({QUICK}) ({STATS})}
+ {TRAIT_IF 8 loyal,intelligent ({LOYAL}) ({INTELLIGENT}) ({STATS})}
+ {TRAIT_IF 9 quick,intelligent ({QUICK}) ({INTELLIGENT}) ({STATS})}
+ #enddef
+
+ #define ORB ID TRAIT DESC NUMBER
+ [if]
+ [variable]
+ name=temprand
+ equals={NUMBER}
+ [/variable]
+ [then]
+ {PLACE ({ID}) items/ball-blue.png () (
+ [object]
+ name= _ "Orb of {DESC}"
+ description= _ "This unit's {DESC} has been increased!"
+ [filter]
+ x=$xloc{ID}
+ y=$yloc{ID}
+ [/filter]
+ {TRAIT}
+ [/object]
+ )}
+ [/then]
+ [/if]
+ #enddef
+
+ #define IF_NONEXIST ID
+ [if]
+ [variable]
+ name={ID}_exists
+ not_equals=yes
+ [/variable]
+ [then]
+ #enddef
+
+ #define /IF_NONEXIST
+ [/then]
+ [/if]
+ #enddef
+
+ #define CREATURE_CAGE ID
+ {PSEUDORANDOM 23}
+ {VARIABLE_OP temprand to_variable random}
+ {CREATURE2 {ID} (Young Ogre) (young-ogre.png) 0}
+ {CREATURE1 {ID} (Spearman) (human-spearman.png) 1}
+ {CREATURE1 {ID} (Bowman) (human-bowman.png) 2}
+ {CREATURE1 {ID} (Cavalryman) (human-scout.png) 3}
+ {CREATURE1 {ID} (Fencer) (human-fencer.png) 4}
+ {CREATURE1 {ID} (Mage) (mage.png) 5}
+ {CREATURE2 {ID} (Heavy Infantryman) (human-heavyinfantry.png) 6}
+ {CREATURE2 {ID} (Elvish Fighter) (elvish-fighter.png) 7}
+ {CREATURE2 {ID} (Elvish Archer) (elvish-archer.png) 8}
+ {CREATURE2 {ID} (Elvish Shaman) (elvish-shaman.png) 9}
+ {CREATURE2 {ID} (Elvish Scout) (elvish-scout.png) 10}
+ {CREATURE2 {ID} (Orcish Grunt) (orcish-grunt.png) 11}
+ {CREATURE2 {ID} (Orcish Archer) (orc-archer.png) 12}
+ {CREATURE2 {ID} (Orcish Assassin) (orc-assassin.png) 13}
+ {CREATURE1 {ID} (Thief) (thief.png) 14}
+ {CREATURE1 {ID} (Footpad) (neutral-footpad.png) 15}
+ {CREATURE1 {ID} (Thug) (neutral-thug.png) 16}
+ {CREATURE1 {ID} (Poacher) (neutral-poacher.png) 17}
+ {CREATURE2 {ID} (Dwarvish Fighter) (dwarf-fighter.png) 18}
+ {CREATURE2 {ID} (Dwarvish Thunderer) (dwarf-thunderer.png) 19}
+ {CREATURE2 {ID} (Dark Adept) (undead-adept.png) 20}
+ {CREATURE2 {ID} (Wolf Rider) (wolf-rider.png) 21}
+ {CREATURE1 {ID} (Sergeant) (human-sergeant.png) 22}
+ #enddef
+
+ [event]
+ name=side turn
+ first_time_only=no
+ [if]
+ [variable]
+ name=turn_number
+ greater_than=1
+ [/variable]
+ [then]
+
+ {IF_NONEXIST a}
+ {PLACE a misc/chest.png () (
+ [gold]
+ side=$unit_side
+ amount=20
+ [/gold]
+ [sound]
+ name=open-chest.wav
+ [/sound]
+ )}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST b}
+ {PLACE b misc/chest.png () (
+ [gold]
+ side=$unit_side
+ amount=20
+ [/gold]
+ [sound]
+ name=open-chest.wav
+ [/sound]
+ )}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST c}
+ {PLACE c misc/chest.png () (
+ [gold]
+ side=$unit_side
+ amount=20
+ [/gold]
+ [sound]
+ name=open-chest.wav
+ [/sound]
+ )}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST d}
+ {PLACE d misc/chest.png () (
+ [gold]
+ side=$unit_side
+ amount=20
+ [/gold]
+ [sound]
+ name=open-chest.wav
+ [/sound]
+ )}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST e}
+ {CREATURE_CAGE e}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST f}
+ {CREATURE_CAGE f}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST g}
+ {CREATURE_CAGE g}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST h}
+ {CREATURE_CAGE h}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST i}
+ {PSEUDORANDOM 4}
+ {VARIABLE_OP temprand to_variable random}
+ {ORB i ({STRONG}) (Strength) 0}
+ {ORB i ({INTELLIGENT}) (Intelligence) 1}
+ {ORB i ({RESILIENT}) (Toughness) 2}
+ {ORB i ({QUICK}) (Quickness) 3}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST j}
+ {PSEUDORANDOM 4}
+ {VARIABLE_OP temprand to_variable random}
+ {ORB j ({STRONG}) (Strength) 0}
+ {ORB j ({INTELLIGENT}) (Intelligence) 1}
+ {ORB j ({RESILIENT}) (Toughness) 2}
+ {ORB j ({QUICK}) (Quickness) 3}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST k}
+ {PSEUDORANDOM 4}
+ {VARIABLE_OP temprand to_variable random}
+ {ORB k ({STRONG}) (Strength) 0}
+ {ORB k ({INTELLIGENT}) (Intelligence) 1}
+ {ORB k ({RESILIENT}) (Toughness) 2}
+ {ORB k ({QUICK}) (Quickness) 3}
+ {/IF_NONEXIST}
+
+ {IF_NONEXIST l}
+ {PSEUDORANDOM 4}
+ {VARIABLE_OP temprand to_variable random}
+ {ORB l ({STRONG}) (Strength) 0}
+ {ORB l ({INTELLIGENT}) (Intelligence) 1}
+ {ORB l ({RESILIENT}) (Toughness) 2}
+ {ORB l ({QUICK}) (Quickness) 3}
+ {/IF_NONEXIST}
+
+ [/then]
+ [/if]
+ [/event]
+
+ [/multiplayer]
||See Also||
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, (continued)
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/15
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration,
wiki <=
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/15
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/16
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/16
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/16
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/16
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/16