Mercurial > skaapsteker
annotate skaapsteker/sprites/npcs.py @ 583:194f71cc0689
don't remove kaneda from the geisha room too early (looks weird, but fixes crash)
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sun, 10 Apr 2011 15:59:59 +0200 |
parents | 1ccb90397c4a |
children | 79a9b61e12ff |
rev | line source |
---|---|
551 | 1 from .base import NPC, BlockingNPC, PC_LAYER, notify |
475
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
2 from pygame import transform |
189
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
3 |
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
4 |
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
5 class Monk(NPC): |
213
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
6 image_dir = 'sprites/monk' |
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
7 animation_regexes = [ |
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
8 ("meditating", "monk.png"), |
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
9 ] |
189
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
10 |
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
11 |
460 | 12 class Guard(BlockingNPC): |
213
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
13 image_dir = 'sprites/guard' |
197 | 14 |
461
c6d1165bb16f
Can talk your way past the guard
Neil Muller <drnlmuller@gmail.com>
parents:
460
diff
changeset
|
15 def update(self): |
c6d1165bb16f
Can talk your way past the guard
Neil Muller <drnlmuller@gmail.com>
parents:
460
diff
changeset
|
16 if not self._me.block and self.block: |
c6d1165bb16f
Can talk your way past the guard
Neil Muller <drnlmuller@gmail.com>
parents:
460
diff
changeset
|
17 self.collides_with = set([]) |
c6d1165bb16f
Can talk your way past the guard
Neil Muller <drnlmuller@gmail.com>
parents:
460
diff
changeset
|
18 self.block = False |
c6d1165bb16f
Can talk your way past the guard
Neil Muller <drnlmuller@gmail.com>
parents:
460
diff
changeset
|
19 super(Guard, self).update() |
197 | 20 |
460 | 21 |
468
73868503c470
Make road Samuri blocking
Neil Muller <drnlmuller@gmail.com>
parents:
461
diff
changeset
|
22 class Hattori(BlockingNPC): |
213
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
23 image_dir = 'sprites/hattori' |
475
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
24 facings = { |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
25 'running' : (('left', None), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
26 ('right', lambda x: transform.flip(x, True, False))), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
27 'standing' : (('left', None), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
28 ('right', lambda x: transform.flip(x, True, False))), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
29 } |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
30 |
501
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
31 def update(self): |
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
32 if not self._me.block: |
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
33 self.remove() |
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
34 |
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
35 |
197 | 36 |
37 | |
468
73868503c470
Make road Samuri blocking
Neil Muller <drnlmuller@gmail.com>
parents:
461
diff
changeset
|
38 class Ichiro(BlockingNPC): |
213
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
39 image_dir = 'sprites/ichiro' |
475
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
40 facings = { |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
41 'running' : (('left', None), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
42 ('right', lambda x: transform.flip(x, True, False))), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
43 'standing' : (('left', None), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
44 ('right', lambda x: transform.flip(x, True, False))), |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
45 } |
18427edff33a
Add facing support to npcs
Neil Muller <drnlmuller@gmail.com>
parents:
468
diff
changeset
|
46 |
501
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
47 def update(self): |
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
48 if not self._me.block: |
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
49 self.remove() |
9a16483e49cb
Remove 1st set of blocking samuri
Neil Muller <drnlmuller@gmail.com>
parents:
475
diff
changeset
|
50 |
197 | 51 |
52 | |
53 class Kaneda(NPC): | |
213
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
54 image_dir = 'sprites/kaneda' |
197 | 55 |
559 | 56 wants_updates = True |
57 | |
544 | 58 animation_regexes = [ |
59 ("standing", r"^.*_standing.png$"), | |
60 ] | |
61 | |
516
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
62 facings = { |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
63 'standing' : (('left', None), |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
64 ('right', lambda x: transform.flip(x, True, False))), |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
65 } |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
66 |
546
05d93c10e5ae
Remove Kaneda after the deal is off
Neil Muller <drnlmuller@gmail.com>
parents:
544
diff
changeset
|
67 def setup(self, name, world, dsm, state, present, facing=None): |
05d93c10e5ae
Remove Kaneda after the deal is off
Neil Muller <drnlmuller@gmail.com>
parents:
544
diff
changeset
|
68 super(Kaneda, self).setup(name, world, dsm, state, facing) |
05d93c10e5ae
Remove Kaneda after the deal is off
Neil Muller <drnlmuller@gmail.com>
parents:
544
diff
changeset
|
69 |
550 | 70 def player_action(self, player): |
546
05d93c10e5ae
Remove Kaneda after the deal is off
Neil Muller <drnlmuller@gmail.com>
parents:
544
diff
changeset
|
71 if not self._me.present: |
550 | 72 return |
73 super(Kaneda, self).player_action(player) | |
74 | |
75 def update(self): | |
583
194f71cc0689
don't remove kaneda from the geisha room too early (looks weird, but fixes crash)
Neil Muller <drnlmuller@gmail.com>
parents:
568
diff
changeset
|
76 super(Kaneda, self).update() |
194f71cc0689
don't remove kaneda from the geisha room too early (looks weird, but fixes crash)
Neil Muller <drnlmuller@gmail.com>
parents:
568
diff
changeset
|
77 if not self._me.present and self.alive and self._me.level == "tea_house": |
568 | 78 self.remove() |
583
194f71cc0689
don't remove kaneda from the geisha room too early (looks weird, but fixes crash)
Neil Muller <drnlmuller@gmail.com>
parents:
568
diff
changeset
|
79 elif self.world.missions.kumiko_disgraced and self.alive and self._me.level == 'geisha_room': |
546
05d93c10e5ae
Remove Kaneda after the deal is off
Neil Muller <drnlmuller@gmail.com>
parents:
544
diff
changeset
|
80 self.remove() |
05d93c10e5ae
Remove Kaneda after the deal is off
Neil Muller <drnlmuller@gmail.com>
parents:
544
diff
changeset
|
81 |
197 | 82 |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
83 class Tetsuo(NPC): |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
84 image_dir = 'sprites/tetsuo' |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
85 |
544 | 86 animation_regexes = [ |
87 ("standing", r"^.*_standing.png$"), | |
88 ] | |
89 | |
90 | |
516
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
91 facings = { |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
92 'standing' : (('left', None), |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
93 ('right', lambda x: transform.flip(x, True, False))), |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
94 } |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
95 |
9a1f8925d227
added facings for kaneda and tetsuo
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
514
diff
changeset
|
96 |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
97 |
197 | 98 class Kumiko(NPC): |
213
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
99 image_dir = 'sprites/geisha' |
197 | 100 |
550 | 101 animation_regexes = [ |
102 ("standing", r"^.*_01.png$"), | |
103 ] | |
104 | |
551 | 105 collides_with = set([PC_LAYER]) |
106 | |
107 def damage(self, damage): | |
108 """Destroy the kimono""" | |
109 if not self.world.missions.kumikos_kimono_torn: | |
110 self.world.missions.kumikos_kimono_torn = True | |
111 notify("Shoo, dirty fox! Oh, look what you've done" | |
559 | 112 "- you've made a great big tear in my finest silk kimono." |
113 "What will the businessman think of a ragged dress like this?") | |
551 | 114 |
197 | 115 |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
116 class FishMonger(NPC): |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
117 image_dir = 'sprites/fishmonger' |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
118 animation_regexes = [ |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
119 ("standing", r"^.*_standing.png$"), |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
120 ] |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
121 |
549
b7f912705adb
Fishmonger now mongers fish.
Jeremy Thurgood <firxen@gmail.com>
parents:
546
diff
changeset
|
122 def setup(self, **opts): |
b7f912705adb
Fishmonger now mongers fish.
Jeremy Thurgood <firxen@gmail.com>
parents:
546
diff
changeset
|
123 super(FishMonger, self).setup(**opts) |
b7f912705adb
Fishmonger now mongers fish.
Jeremy Thurgood <firxen@gmail.com>
parents:
546
diff
changeset
|
124 self.world.missions.fishmonger_demons_killed = 0 |
b7f912705adb
Fishmonger now mongers fish.
Jeremy Thurgood <firxen@gmail.com>
parents:
546
diff
changeset
|
125 |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
126 |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
127 class Maneki(NPC): |
436
32df272a163a
maneki neko and fisherman's house
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
418
diff
changeset
|
128 image_dir = 'sprites/maneki neko' |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
129 animation_regexes = [ |
436
32df272a163a
maneki neko and fisherman's house
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
418
diff
changeset
|
130 ("standing", r"^.*_standing.png$"), |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
131 ] |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
132 |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
133 |
197 | 134 class Actor(NPC): |
418
c6e9b3006ef9
stuff in theatre
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
297
diff
changeset
|
135 image_dir = 'sprites/fishmonger' |
224
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
136 animation_regexes = [ |
418
c6e9b3006ef9
stuff in theatre
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
297
diff
changeset
|
137 ("standing", r"^.*_standing.png$"), |
224
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
138 ] |
197 | 139 |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
224
diff
changeset
|
140 |
509
c85363a8ff56
Make Sasuke non-blocking again
Neil Muller <drnlmuller@gmail.com>
parents:
501
diff
changeset
|
141 class Sasuke(NPC): |
213
c5c4306593d8
Attempt to animate NPCs a bit.
Simon Cross <hodgestar@gmail.com>
parents:
197
diff
changeset
|
142 image_dir = 'sprites/sasuke' |
224
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
143 |
525 | 144 def setup(self, name, world, dsm, state, present, facing=None): |
514 | 145 self._animation = 'standing' |
146 super(Sasuke, self).setup(name, world, dsm, state, facing) | |
147 | |
525 | 148 def update(self): |
149 if not self._me.present: | |
150 self.remove() | |
526
5613f7b61b23
Stop Sasuke falling off the world
Neil Muller <drnlmuller@gmail.com>
parents:
525
diff
changeset
|
151 super(Sasuke, self).update() |
224
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
152 |
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
153 class Kitsune(NPC): |
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
154 image_dir = 'sprites' |
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
155 animation_regexes = [ |
451 | 156 ("being_evil", "boss_kitsune.png"), |
224
5d37c73d46e2
Fix actor sprite a bit. Add evil kitsune sprite.
Simon Cross <hodgestar@gmail.com>
parents:
213
diff
changeset
|
157 ] |