From 9335e0f4d294fb942d68b179c20a11a8d6212fa0 Mon Sep 17 00:00:00 2001 From: tchize Date: Sat, 17 Nov 2007 17:38:05 +0000 Subject: [PATCH] add a werebeast script and demo The demo "werebeast" is based on beholder transforming into black dragon Updated sage opening door message git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@7519 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/tod/replace_all_periods.py | 93 ++++++++++++++ python/tod/replace_one_period.py | 93 ++++++++++++++ test/tod | 195 ++++++++++++++++++++++++++---- 3 files changed, 357 insertions(+), 24 deletions(-) create mode 100644 python/tod/replace_all_periods.py create mode 100644 python/tod/replace_one_period.py diff --git a/python/tod/replace_all_periods.py b/python/tod/replace_all_periods.py new file mode 100644 index 000000000..87d4aeeb6 --- /dev/null +++ b/python/tod/replace_all_periods.py @@ -0,0 +1,93 @@ +# push_one_period.py +# +# Copyright 2007 by David Delbecq +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +# +# This script make the object is is attached to swap at +# given periods of day with a specifc object in the event's inventory +# To use it, give this event's parameter the name of +# period where the swap is active. Put in the inventiry the swapped object +# The swap can occur for objects in map and for object in other object +# +# exemple +# +# arch event_time +# title Python +# slaying /python/tod/replace_one_period.py +# name Morning,Noon +# arch beholder +# end +# end +# +# parameters are separated by comas. Those +# are the periods of day where the swap is active + + +import Crossfire +import string +event = Crossfire.WhatIsEvent() +alreadymatched = (event.Value!=0) + +parameters = string.split(Crossfire.ScriptParameters(),",") +now = Crossfire.GetTime() +current = [Crossfire.GetMonthName(now[1]),Crossfire.GetWeekdayName(now[5]),Crossfire.GetSeasonName(now[7]),Crossfire.GetPeriodofdayName(now[8])] +if (set(parameters) - set(current)): + match = False +else: + match = True +if ( (match and (not alreadymatched)) or (alreadymatched and (not match))): + Crossfire.Log(Crossfire.LogDebug, "replace_one_period") + event = Crossfire.WhatIsEvent() + current = Crossfire.WhoAmI() + future = event.Inventory + # we do not want to repace a monster/anything useable in game by a subevent on the event. + # seems for technical reasons, EVENT object have a destroy subevent. So let's just + # ignore subevents + while ( (future != None) & (future.Type == Crossfire.Type.EVENT_CONNECTOR)): + future=future.Below + if (future): + if (future.Below): + Crossfire.Log(Crossfire.LogDebug, "future.Below is %s" %future.Below.Name) + Crossfire.Log(Crossfire.LogDebug, "current is %s, future is %s, event is %s" %(current.Name, future.Name, event.Name)) + if (current.Env): + Crossfire.Log(Crossfire.LogDebug, "env mode") + env = current.Env + future.InsertInto(env) + event.InsertInto(future) + current.InsertInto(event) + if (alreadymatched): + event.Value=0 + else: + event.Value=1 + elif (current.Map): + Crossfire.Log(Crossfire.LogDebug, "Map mode") + mymap = current.Map + x = current.X + y = current.Y + Crossfire.Log(Crossfire.LogDebug, "inserting future %s in map" %future.Name) + mymap.Insert(future,x,y) + Crossfire.Log(Crossfire.LogDebug, "inserting event %s in future" %event.Name) + event.InsertInto(future) + Crossfire.Log(Crossfire.LogDebug, "inserting current %s in event" %current.Name) + current.InsertInto(event) + if (alreadymatched): + event.Value=0 + else: + event.Value=1 + else: + Crossfire.Log(Crossfire.LogDebug, "neither env object nor map found") diff --git a/python/tod/replace_one_period.py b/python/tod/replace_one_period.py new file mode 100644 index 000000000..646091a61 --- /dev/null +++ b/python/tod/replace_one_period.py @@ -0,0 +1,93 @@ +# push_one_period.py +# +# Copyright 2007 by David Delbecq +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +# +# This script make the object is is attached to swap at +# given periods of day with a specifc object in the event's inventory +# To use it, give this event's parameter the name of +# period where the swap is active. Put in the inventiry the swapped object +# The swap can occur for objects in map and for object in other object +# +# exemple +# +# arch event_time +# title Python +# slaying /python/tod/replace_one_period.py +# name Morning,Noon +# arch beholder +# end +# end +# +# parameters are separated by comas. Those +# are the periods of day where the swap is active + + +import Crossfire +import string +event = Crossfire.WhatIsEvent() +alreadymatched = (event.Value!=0) + +parameters = string.split(Crossfire.ScriptParameters(),",") +now = Crossfire.GetTime() +current = [Crossfire.GetMonthName(now[1]),Crossfire.GetWeekdayName(now[5]),Crossfire.GetSeasonName(now[7]),Crossfire.GetPeriodofdayName(now[8])] +if (set(parameters) & set(current)): + match = True +else: + match = False +if ( (match and (not alreadymatched)) or (alreadymatched and (not match))): + Crossfire.Log(Crossfire.LogDebug, "replace_one_period") + event = Crossfire.WhatIsEvent() + current = Crossfire.WhoAmI() + future = event.Inventory + # we do not want to repace a monster/anything useable in game by a subevent on the event. + # seems for technical reasons, EVENT object have a destroy subevent. So let's just + # ignore subevents + while ( (future != None) & (future.Type == Crossfire.Type.EVENT_CONNECTOR)): + future=future.Below + if (future): + if (future.Below): + Crossfire.Log(Crossfire.LogDebug, "future.Below is %s" %future.Below.Name) + Crossfire.Log(Crossfire.LogDebug, "current is %s, future is %s, event is %s" %(current.Name, future.Name, event.Name)) + if (current.Env): + Crossfire.Log(Crossfire.LogDebug, "env mode") + env = current.Env + future.InsertInto(env) + event.InsertInto(future) + current.InsertInto(event) + if (alreadymatched): + event.Value=0 + else: + event.Value=1 + elif (current.Map): + Crossfire.Log(Crossfire.LogDebug, "Map mode") + mymap = current.Map + x = current.X + y = current.Y + Crossfire.Log(Crossfire.LogDebug, "inserting future %s in map" %future.Name) + mymap.Insert(future,x,y) + Crossfire.Log(Crossfire.LogDebug, "inserting event %s in future" %event.Name) + event.InsertInto(future) + Crossfire.Log(Crossfire.LogDebug, "inserting current %s in event" %current.Name) + current.InsertInto(event) + if (alreadymatched): + event.Value=0 + else: + event.Value=1 + else: + Crossfire.Log(Crossfire.LogDebug, "neither env object nor map found") diff --git a/test/tod b/test/tod index 3c979fef7..0318b6435 100644 --- a/test/tod +++ b/test/tod @@ -1,11 +1,11 @@ arch map name tod -darkness 3 +darkness 1 width 20 height 20 msg Created: 2007-11-11 tchize -Modified: 2007-11-16 tchize +Modified: 2007-11-17 tchize endmsg end arch brush @@ -1362,7 +1362,7 @@ arch brush x 10 y 7 end -arch brush +arch afloor_blue_right x 10 y 8 end @@ -1445,7 +1445,7 @@ arch brush x 11 y 7 end -arch brush +arch afloor_blue_right x 11 y 8 end @@ -1528,7 +1528,7 @@ arch brush x 12 y 7 end -arch brush +arch afloor_blue_right x 12 y 8 end @@ -1610,7 +1610,7 @@ arch brush x 13 y 7 end -arch brush +arch afloor_blue_right x 13 y 8 end @@ -1693,51 +1693,51 @@ arch brush x 14 y 7 end -arch brush +arch afloor_blue_right x 14 y 8 end -arch brush +arch afloor_blue_left x 14 y 9 end -arch brush +arch afloor_blue_left x 14 y 10 end -arch brush +arch afloor_blue_left x 14 y 11 end -arch brush +arch afloor_blue_left x 14 y 12 end -arch brush +arch afloor_blue_left x 14 y 13 end -arch brush +arch afloor_blue_left x 14 y 14 end -arch brush +arch afloor_blue_left x 14 y 15 end -arch brush +arch afloor_blue_left x 14 y 16 end -arch brush +arch afloor_blue_left x 14 y 17 end -arch brush +arch afloor_blue_left x 14 y 18 end -arch brush +arch afloor_blue_left x 14 y 19 end @@ -1776,7 +1776,7 @@ arch brush x 15 y 7 end -arch brush +arch afloor_blue_right x 15 y 8 end @@ -1788,14 +1788,26 @@ arch brush x 15 y 10 end +arch swall_2_2_2 +x 15 +y 10 +end arch brush x 15 y 11 end +arch swall_2_1_1 +x 15 +y 11 +end arch brush x 15 y 12 end +arch swall_2_2_1 +x 15 +y 12 +end arch brush x 15 y 13 @@ -1810,12 +1822,23 @@ y 15 end arch magic_mouth msg -You see the sage activating the doors +You see the sage opening the doors endmsg x 15 y 15 connected 79 move_on 0 +activate_on_release 0 +end +arch magic_mouth +msg +You see the sage closing the doors +endmsg +x 15 +y 15 +connected 79 +move_on 0 +activate_on_push 0 end arch sage msg @@ -1897,7 +1920,7 @@ arch brush x 16 y 7 end -arch brush +arch afloor_blue_right x 16 y 8 end @@ -1905,18 +1928,47 @@ arch brush x 16 y 9 end +arch sign +msg +This beholder changes to black dragon at Dusk and Night +endmsg +x 16 +y 9 +end arch brush x 16 y 10 end +arch swall_2_1_2 +x 16 +y 10 +end arch brush x 16 y 11 end +arch beholder +x 16 +y 11 +connected 80 +arch event_trigger +name Dusk,Night +title Python +slaying /python/tod/replace_one_period.py +subtype 8 +arch black_dragon1 +connected 80 +end +end +end arch brush x 16 y 12 end +arch swall_2_1_2 +x 16 +y 12 +end arch brush x 16 y 13 @@ -1988,7 +2040,7 @@ arch brush x 17 y 7 end -arch brush +arch afloor_blue_right x 17 y 8 end @@ -1996,22 +2048,59 @@ arch brush x 17 y 9 end +arch light4 +x 17 +y 9 +end +arch sign +msg +This beholder transforms to blackdragon at dawn and morning +endmsg +x 17 +y 9 +end arch brush x 17 y 10 end +arch swall_2_1_2 +x 17 +y 10 +end arch brush x 17 y 11 end +arch beholder +x 17 +y 11 +connected 80 +arch event_trigger +name Dawn,Morning +title Python +slaying /python/tod/replace_one_period.py +subtype 8 +arch black_dragon1 +connected 80 +end +end +end arch brush x 17 y 12 end +arch swall_2_1_2 +x 17 +y 12 +end arch brush x 17 y 13 end +arch light4 +x 17 +y 13 +end arch brush x 17 y 14 @@ -2079,7 +2168,7 @@ arch brush x 18 y 7 end -arch brush +arch afloor_blue_right x 18 y 8 end @@ -2087,18 +2176,47 @@ arch brush x 18 y 9 end +arch sign +msg +This beholder transforms to b lack dragon at Noon and evening +endmsg +x 18 +y 9 +end arch brush x 18 y 10 end +arch swall_2_1_2 +x 18 +y 10 +end arch brush x 18 y 11 end +arch beholder +x 18 +y 11 +connected 80 +arch event_trigger +name Noon,Evening +title Python +slaying /python/tod/replace_one_period.py +subtype 8 +arch black_dragon1 +connected 80 +end +end +end arch brush x 18 y 12 end +arch swall_2_1_2 +x 18 +y 12 +end arch brush x 18 y 13 @@ -2194,7 +2312,7 @@ arch brush x 19 y 7 end -arch brush +arch afloor_blue_right x 19 y 8 end @@ -2202,18 +2320,47 @@ arch brush x 19 y 9 end +arch sign +msg +This beholder transforms to black dragon at evening and Dusk +endmsg +x 19 +y 9 +end arch brush x 19 y 10 end +arch swall_1_3 +x 19 +y 10 +end arch brush x 19 y 11 end +arch beholder +x 19 +y 11 +connected 80 +arch event_trigger +name Evening,Dusk +title Python +slaying /python/tod/replace_one_period.py +subtype 8 +arch black_dragon1 +connected 80 +end +end +end arch brush x 19 y 12 end +arch swall_1_3 +x 19 +y 12 +end arch brush x 19 y 13