Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
indexing description: "Dragon actors" author: "Remlie Ortencio" date: "13-10-2012" last_modified: "13-10-2012" class DRAGON inherit HOBBIT_ACTOR redefine make, act end create {HOBBIT_OBJECT_FACTORY} -- a DRAGON can only be created by a -- HOBBIT_OBJECT_FACTORY make feature{NONE} -- private attributes sleeping: BOOLEAN -- check on whether dragon is awake or asleep hoard_location: LOCATION -- records where dragon's hoard is to allow it to return travel_direction: INTEGER -- index into directions next_location: LOCATION -- where the dragon is to move next attack_command: ATTACK_COMMAND -- our own private attack command, which we will not make visible to others feature{NONE} -- creation make(new_name: STRING; new_description: STRING; the_simulation: HOBBIT_SIMULATION) is local weapon: OBJECT take_command: TAKE_COMMAND do precursor(new_name, new_description, the_simulation) -- give the dragon an "active attack" command, which it will use to attack other actors it encounters -- this is different from the "passive" attack commands that all HOBBIT_ACTOR actors have, that allows them to be attacked create attack_command.make ("active attack", "<actor>") attack_command.set_actor(current) -- Give the dragon jaws of fire, as blasting actors with fire is what they do best -- Handled this way for simplicity, will need to handle deletion of weapon upon defeat (if ever possible, assumed immortal from currently implemented attacks) weapon := simulation.object_factory.create_object(new_name + "'s Jaws of Fire", "the dragon's source of deathly hot flames") weapon.set_symbol('') -- research on what this means and what symbol to use create take_command.make("take", "<object>") take_command.set_object(weapon) weapon.add_command(take_command) weapon.set_points(999,999) -- assuming this is damage points, research required take_command.set_actor(current) take_command.execute -- doing it this way ensures that house-keeping is done -- initialize behaviour sleeping := TRUE -- sleeps and does nothing until it wakes end -- make feature -- game action act is -- the Dragon behaviour for The Hobbit game require else valid_location: location /= void -- the location must be set before the first call to act, as this defines the dragon's hoard's location local wake_chance: INTEGER -- holds a value between 1 to 10 to determine when dragon wakes do -- ### Initial Behaviour if hoard_location = void then hoard_location := location -- set the hoard location on the first call to act end if sleeping = TRUE then -- Dragon is still asleep -- code to wake up dragon at a 10% chance here wake_chance := simulation.random_generator.random_value_from_range(1, 10) if wake_chance = 1 then sleeping := FALSE simulation.interface.put_message(name + " has woken up!") set_up_travel -- decides where to go upon waking end -- inner if else move if location = hoard_location then sleeping := TRUE else attack end -- else if end -- outer if end -- act feature{NONE} -- private meathods set_up_travel is -- method to decide where the dragon will move to next local location_check: LOCATION do travel_direction := simulation.random_generator.random_value_from_range(directions.lower, directions.upper) location_check := location.get_path(directions.item(travel_direction)) if location_check = void then set_up_travel -- should call itself until a valid direction is found, for when dragon is sleeping at edge of grid end end -- set_up_travel move is -- handles dragon moving from hoard and back -- navigation used to return to hoard here is the same as the method used in the REPLICATOR class -- this form of navigation is used in case dragon encounters water (while unlikely, used just in case) -- Note: does not handle if dragon is moving against water current local next_location: LOCATION current_direction: INTEGER do if location /= hoard_location then from current_direction := directions.lower until current_direction >= directions.upper loop next_location := get_closer_location(current_target.location, next_location, location.get_path(directions.item(current_direction))) current_direction := current_direction + 1 end -- loop else next_location := location.get_path(directions.item(travel_direction)) end set_location(next_location) end -- move attack is -- handles dragon attacking when it finds visible actor(s) in the area it is currently in local obj_list: LINKED_LIST[STRING] obj: OBJECT attack_obj_list: LINKED_LIST[STRING] attack_area: INTEGER next_location: LOCATION -- next location to check what area to apply attack commands in attack_area_list: LINKED_LIST[STRING] attack_obj: OBJECT do obj_list := location.list_contents if obj_list /= void then from obj_list.start until obj_list.off loop obj := location.get_contents(object_name_from_list_entry(obj_list.item)) if obj.team_id /= simulation.default_team_id and obj.team_id /= team_id then -- we have found something to attack -- replace following code with code to attack all actors in the area, invisible or not --attack_command.set_object(obj) --attack_command.execute simulation.interface.put_message("An attack has been launched! " + name + weapon.get_name + " damages everyone in the area!") from attack_area := directions.lower until attack_area >= directions.upper + 1 loop next_location := location.get_path(directions.item(attack_area))) -- area attack code here attack_area_list := next_location.list_contents if attack_area_list /= void then from attack_area_list.start until attack_area_list.off loop attack_obj := location.get_contents(object_name_from_list_entry(attack_area_list.item)) if attack_obj.team_id /= simulation.default_team_id and attack_obj.team_id /= team_id then -- we have found something to attack attack_command.set_actor(current) -- attack_command.set_object(attack_obj) attack_command.execute attack_command.set_actor(void) end -- if attack_area_list.forth end -- loop end -- if -- area attack code end attack_area := attack_area + 1 end end -- if obj_list.off end -- loop end -- if end -- attack -- TODO: -- Make Dragon sleep with 10% chance of waking -- When awake, make it move in one random direction, then check if actor can be seen in the area the dragon moved to -- if visible actor exists, then attack, which also damages all actors in the area and all adjacent areas -- after moving/attacking, go back to hoard -- add treasure objects (look at hobbit_application object_factory) end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
✅ MAKE $1200 IN 15 MIN S8
JavaScript | 2 sec ago | 0.09 KB
MAKE $500 INSTANTLY QZ
JavaScript | 3 sec ago | 0.09 KB
Make $1200 in 15 minutes
JavaScript | 5 sec ago | 0.08 KB
MAKE $500 INSTANTLY 5L
JavaScript | 8 sec ago | 0.09 KB
MAKE $500 INSTANTLY 6L
JavaScript | 8 sec ago | 0.09 KB
MAKE $500 INSTANTLY GD
JavaScript | 9 sec ago | 0.09 KB
Netflix Premium UHD Hits
JavaScript | 10 sec ago | 0.08 KB
✅ MAKE $1200 IN 15 MIN L7
JavaScript | 12 sec ago | 0.09 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!