[NoGo] Whack-a-Tree

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Simn
Engineer
Engineer
Posts: 15
Joined: 05 Jan 2012 19:43

[NoGo] Whack-a-Tree

Post by Simn »

Here's the completely pointless first result of my venture into OpenTTD scripting: Whack-a-Tree.

How to play:
1. Find a 5x5 area that can be safely demolished.
2. Place a sign in the middle and label it !play
3. Pick your favorite demolition tool and whack away at them trees!

You can cheat by constantly clearing the whole area, but I couldn't decide on any not-to-whack element to randomly spawn. Other than that, the game only wastes your time and money, but it serves as a proof of concept for games using NoGo.

Note to script developers: The EventDispatcher, SignObserver and event classes are part of a library I started building. If you think they might be useful (I have StationObserver and HQObserver as well) let me know and I will release them as a library.

Edit: Setting the spawn chance too 100% causes no tree spawn at all. I blame GSBase.Chance().
Attachments
whackatree-1.tar
(16 KiB) Downloaded 140 times
User avatar
JacobD88
Chief Executive
Chief Executive
Posts: 708
Joined: 16 Aug 2008 17:51
Location: Long Eaton, Nottinghamshire. UK
Contact:

Re: [NoGo] Whack-a-Tree

Post by JacobD88 »

As "pointless" things go, i think this is a great little mini-game. Thanks for upload! :bow:
oberhümer
Tycoon
Tycoon
Posts: 1283
Joined: 23 Oct 2009 19:35
Location: Here and there, sometime or another

Re: [NoGo] Whack-a-Tree

Post by oberhümer »

How about giving money back to the player based on some formula with the hit percentage (if that works) and the number of trees cleared in it? Of course, it would destroy the whole purpose by making it useful, but that's your decision :P
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---

--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
oberhümer
Tycoon
Tycoon
Posts: 1283
Joined: 23 Oct 2009 19:35
Location: Here and there, sometime or another

Re: [NoGo] Whack-a-Tree

Post by oberhümer »

Tiny update - configurable radius. I wanted to make it catch cheaters (i.e. those who dynamite more than one tree at once), but it turns out scripts run much too slow for that. I haven't figured out a way to directly refund money yet either.
Attachments
whackatree-1.tar
(30 KiB) Downloaded 118 times
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---

--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4765
Joined: 09 Sep 2007 05:03
Location: home

Re: [NoGo] Whack-a-Tree

Post by Alberth »

Simn wrote:Setting the spawn chance too 100% causes no tree spawn at all. I blame GSBase.Chance().
You blamed quite correctly :)
Fixed in r24531.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 13 guests