Scripting ideas
-
TB_
Post Demon
- Posts: 998
- Joined: Tue Nov 20, 2012 6:59 pm
This was a mistake thepolm, you're now forever our scripting slave.
-
XxXAtlanXxX
Deuced Up - Posts: 557
- Joined: Sun Dec 16, 2012 12:26 am
-
thepolm3
Scripter
- Posts: 424
- Joined: Sat Feb 16, 2013 10:49 pm
NOOOOOOOO
*wipes eyes
*sniffs
OK
*sniffs
form an orderly que
:P
heheh, its OK, I enjoy scripting, and it's great practice!
*wipes eyes
*sniffs
OK
*sniffs
form an orderly que
:P
heheh, its OK, I enjoy scripting, and it's great practice!
-
matthew0901
Deuced Up - Posts: 105
- Joined: Wed Nov 21, 2012 12:23 pm
SOMEONE MAKE A MAP FOR THE TOURNAMENT GAMEMODE please!!! I want to host it!

-
danhezee
Former Admin / Co-founder
- Posts: 1710
- Joined: Wed Oct 03, 2012 12:09 am
Hi thepolm3
if you get some time checkout this post and see if you can fix match.py for the league system
http://www.buildandshoot.com/viewtopic. ... 551#p24551
if you get some time checkout this post and see if you can fix match.py for the league system
http://www.buildandshoot.com/viewtopic. ... 551#p24551

-
Ninja_pig_pro
Build and Shoot's 1st Birthday
- Posts: 418
- Joined: Thu Dec 20, 2012 1:24 pm
thepolm3 wrote:COOKIESXxXAtlanXxX wrote:How about a gamemode which is existing in RO and Bf3?Oh! Didn't see your post there
Its called "Rush" in bf3.
Maybe a mix of last stand and tow.
Blue team starts as defending team with limited respawns per round and 4 control points.
Green starts as attacker with unlimited tickets and they have to cap all cps in a limited amount of time.
After one team won, roles change.
I hope it was all understandable ;).
I'm worn out at the moment, will start it tomorrow at four. Meanwhile have a cookie
COOKIES
COOKIES
COOKIES
COOKIES
COOKIES
COOKIES
COOKIES
COOKIES

kill me
-
TB_
Post Demon
- Posts: 998
- Joined: Tue Nov 20, 2012 6:59 pm
matthew0901 wrote:SOMEONE MAKE A MAP FOR THE TOURNAMENT GAMEMODE please!!! I want to host it!
dude
http://buildandshoot.com/viewtopic.php?p=24137#p24137
-
matthew0901
Deuced Up - Posts: 105
- Joined: Wed Nov 21, 2012 12:23 pm
TB_ wrote:There is no txt file so.matthew0901 wrote:SOMEONE MAKE A MAP FOR THE TOURNAMENT GAMEMODE please!!! I want to host it!
dude
http://buildandshoot.com/viewtopic.php?p=24137#p24137

-
TB_
Post Demon
- Posts: 998
- Joined: Tue Nov 20, 2012 6:59 pm
matthew0901 wrote:That wasn't what you asked, but go on the IRC and see if someone know how to do that. I know influx does, he made the last stand gamemode.TB_ wrote:There is no txt file so.matthew0901 wrote:SOMEONE MAKE A MAP FOR THE TOURNAMENT GAMEMODE please!!! I want to host it!
dude
http://buildandshoot.com/viewtopic.php?p=24137#p24137
-
thepolm3
Scripter
- Posts: 424
- Joined: Sat Feb 16, 2013 10:49 pm
danhezee wrote:Hi thepolm3Here is your match.py, oh great admin!
if you get some time checkout this post and see if you can fix match.py for the league system
http://www.buildandshoot.com/viewtopic. ... 551#p24551
Code: Select all
I hope it is up to your specifications
"""
Match script, useful for public matches. Features verbose announcements
on IRC and a custom timer.
Maintainer: mat^2
edited by thepolm3
"""
from commands import add, admin, name, get_team
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
import json
import commands
COMMAND_POS=None
@admin
@name('timer')
def start_timer(connection, end):
return connection.protocol.start_timer(int(end)*60)
@admin
@name('stoptimer')
def stop_timer(connection):
return connection.protocol.stop_timer()
@admin
@name('startrecord')
def start_record(connection):
connection.protocol.start_record()
return 'Recording started.'
@admin
@name('stoprecord')
def stop_record(connection):
connection.protocol.stop_record()
return 'Recording stopped.'
@admin
@name('saverecord')
def save_record(connection, value):
if not connection.protocol.save_record(value):
return 'No record file available.'
return 'Record saved.'
add(start_timer)
add(stop_timer)
add(start_record)
add(stop_record)
add(save_record)
def apply_script(protocol, connection, config):
class MatchConnection(connection):
def on_flag_take(self):
self.add_message("%s took %s's flag!" %
(self.printable_name, self.team.other.name.lower()))
return connection.on_flag_take(self)
def on_flag_drop(self):
self.add_message("%s dropped %s's flag!" %
(self.printable_name, self.team.other.name.lower()))
return connection.on_flag_drop(self)
def on_flag_capture(self):
self.add_message("%s captured %s's flag!" %
(self.printable_name, self.team.other.name.lower()))
return connection.on_flag_capture(self)
def on_line_build_attempt(self, points):
if self.protocol.timer_end:
return connection.on_line_build_attempt(self,points)
return False
def on_block_build_attempt(self, x, y, z):
if self.protocol.timer_end:
return connection.on_block_build_attempt(self,x,y,z)
return False
def on_block_destroy(self, x, y, z,value):
if self.protocol.timer_end:
return connection.on_block_destroy(self,x,y,z,value)
return False
def on_kill(self, killer, type, grenade):
if not self.protocol.timer_end:
if killer==self or killer==None:
return connection.on_kill(self,killer,type,grenade)
return False
if killer is None:
killer = self
self.add_message("%s was killed by %s!" %
(self.printable_name, killer.printable_name))
self.protocol.add_kill(self, killer)
return connection.on_kill(self, killer, type, grenade)
def add_message(self, value):
self.protocol.messages.append(value)
class MatchProtocol(protocol):
timer_left = None
timer_call = None
timer_end = None
record = None
blue_command=(0,0,0)
green_command=(0,0,0)
def __init__(self, *arg, **kw):
protocol.__init__(self, *arg, **kw)
self.messages = []
self.send_message_loop = LoopingCall(self.display_messages)
self.send_message_loop.start(3)
def start_timer(self, end):
if self.timer_end is not None:
return 'Timer is running already.'
self.timer_end = reactor.seconds() + end
if end/60==1:
unit="minute"
end/=60
elif end/60>1:
unit="minutes"
end/=60
else:
unit="seconds"
self.send_chat('Timer started, ending in %d %s' % (end,unit),
irc = True)
self.display_timer(True)
for name in self.players:
player=self.players[name]
if player.world_object:
if player.team==get_team(player,"blue"):
player.spawn(self.blue_command)
else:
player.spawn(self.green_command)
def stop_timer(self):
if self.timer_call is not None:
self.timer_call.cancel()
self.send_chat('Timer stopped.')
self.timer_call = None
self.timer_end = None
else:
return 'No timer in progress.'
def display_timer(self, silent = False):
time_left = self.timer_end - reactor.seconds()
minutes_left = time_left / 60.0
next_call = 60
if not silent:
if time_left <= 0:
self.send_chat('Timer ended!', irc = True)
self.timer_end = None
return
elif minutes_left <= 1:
self.send_chat('%s seconds left' % int(time_left),
irc = True)
next_call = max(1, int(time_left / 2.0))
else:
self.send_chat('%s minutes left' % int(minutes_left),
irc = True)
self.timer_call = reactor.callLater(next_call, self.display_timer)
def display_messages(self):
if not self.messages:
return
message = self.messages.pop(0)
self.irc_say(message)
# recording
def add_kill(self, player, killing_player):
if self.record is None:
return
self.get_record(player.name)['deaths'] += 1
self.get_record(killing_player.name)['kills'] += 1
def get_record(self, name):
try:
return self.record[name]
except KeyError:
record = {'deaths' : 0, 'kills' : 0}
self.record[name] = record
return record
def start_record(self):
self.record = {}
def stop_record(self):
self.record = None
def save_record(self, value):
if self.record is None:
return False
json.dump(self.record, open(value, 'wb'))
return True
def on_base_spawn(self, x, y, z, base, entity_id):
if entity_id==2:
self.blue_command=(x,y,z)
else:
self.green_command=(x,y,z)
return protocol.on_base_spawn(self,x,y,z,base,entity_id)
return MatchProtocol, MatchConnection
-
TB_
Post Demon
- Posts: 998
- Joined: Tue Nov 20, 2012 6:59 pm
Did you have that scripter badge before you created this thread? If not, then congrats.
-
thepolm3
Scripter
- Posts: 424
- Joined: Sat Feb 16, 2013 10:49 pm
No I didn't ^^ and thankyou. It took me one and a half weeks from my first script ^^
-
danhezee
Former Admin / Co-founder
- Posts: 1710
- Joined: Wed Oct 03, 2012 12:09 am
thepolm3 wrote:Cool, I will be testing it out later today. Thanks for the quick turnarounddanhezee wrote:Hi thepolm3Here is your match.py, oh great admin!
if you get some time checkout this post and see if you can fix match.py for the league system
http://www.buildandshoot.com/viewtopic. ... 551#p24551
Code: Select allI hope it is up to your specifications""" Match script, useful for public matches. Features verbose announcements on IRC and a custom timer. Maintainer: mat^2 edited by thepolm3 """ from commands import add, admin, name, get_team from twisted.internet import reactor from twisted.internet.task import LoopingCall import json import commands COMMAND_POS=None @admin @name('timer') def start_timer(connection, end): return connection.protocol.start_timer(int(end)*60) @admin @name('stoptimer') def stop_timer(connection): return connection.protocol.stop_timer() @admin @name('startrecord') def start_record(connection): connection.protocol.start_record() return 'Recording started.' @admin @name('stoprecord') def stop_record(connection): connection.protocol.stop_record() return 'Recording stopped.' @admin @name('saverecord') def save_record(connection, value): if not connection.protocol.save_record(value): return 'No record file available.' return 'Record saved.' add(start_timer) add(stop_timer) add(start_record) add(stop_record) add(save_record) def apply_script(protocol, connection, config): class MatchConnection(connection): def on_flag_take(self): self.add_message("%s took %s's flag!" % (self.printable_name, self.team.other.name.lower())) return connection.on_flag_take(self) def on_flag_drop(self): self.add_message("%s dropped %s's flag!" % (self.printable_name, self.team.other.name.lower())) return connection.on_flag_drop(self) def on_flag_capture(self): self.add_message("%s captured %s's flag!" % (self.printable_name, self.team.other.name.lower())) return connection.on_flag_capture(self) def on_line_build_attempt(self, points): if self.protocol.timer_end: return connection.on_line_build_attempt(self,points) return False def on_block_build_attempt(self, x, y, z): if self.protocol.timer_end: return connection.on_block_build_attempt(self,x,y,z) return False def on_block_destroy(self, x, y, z,value): if self.protocol.timer_end: return connection.on_block_destroy(self,x,y,z,value) return False def on_kill(self, killer, type, grenade): if not self.protocol.timer_end: if killer==self or killer==None: return connection.on_kill(self,killer,type,grenade) return False if killer is None: killer = self self.add_message("%s was killed by %s!" % (self.printable_name, killer.printable_name)) self.protocol.add_kill(self, killer) return connection.on_kill(self, killer, type, grenade) def add_message(self, value): self.protocol.messages.append(value) class MatchProtocol(protocol): timer_left = None timer_call = None timer_end = None record = None blue_command=(0,0,0) green_command=(0,0,0) def __init__(self, *arg, **kw): protocol.__init__(self, *arg, **kw) self.messages = [] self.send_message_loop = LoopingCall(self.display_messages) self.send_message_loop.start(3) def start_timer(self, end): if self.timer_end is not None: return 'Timer is running already.' self.timer_end = reactor.seconds() + end if end/60==1: unit="minute" end/=60 elif end/60>1: unit="minutes" end/=60 else: unit="seconds" self.send_chat('Timer started, ending in %d %s' % (end,unit), irc = True) self.display_timer(True) for name in self.players: player=self.players[name] if player.world_object: if player.team==get_team(player,"blue"): player.spawn(self.blue_command) else: player.spawn(self.green_command) def stop_timer(self): if self.timer_call is not None: self.timer_call.cancel() self.send_chat('Timer stopped.') self.timer_call = None self.timer_end = None else: return 'No timer in progress.' def display_timer(self, silent = False): time_left = self.timer_end - reactor.seconds() minutes_left = time_left / 60.0 next_call = 60 if not silent: if time_left <= 0: self.send_chat('Timer ended!', irc = True) self.timer_end = None return elif minutes_left <= 1: self.send_chat('%s seconds left' % int(time_left), irc = True) next_call = max(1, int(time_left / 2.0)) else: self.send_chat('%s minutes left' % int(minutes_left), irc = True) self.timer_call = reactor.callLater(next_call, self.display_timer) def display_messages(self): if not self.messages: return message = self.messages.pop(0) self.irc_say(message) # recording def add_kill(self, player, killing_player): if self.record is None: return self.get_record(player.name)['deaths'] += 1 self.get_record(killing_player.name)['kills'] += 1 def get_record(self, name): try: return self.record[name] except KeyError: record = {'deaths' : 0, 'kills' : 0} self.record[name] = record return record def start_record(self): self.record = {} def stop_record(self): self.record = None def save_record(self, value): if self.record is None: return False json.dump(self.record, open(value, 'wb')) return True def on_base_spawn(self, x, y, z, base, entity_id): if entity_id==2: self.blue_command=(x,y,z) else: self.green_command=(x,y,z) return protocol.on_base_spawn(self,x,y,z,base,entity_id) return MatchProtocol, MatchConnection

-
danhezee
Former Admin / Co-founder
- Posts: 1710
- Joined: Wed Oct 03, 2012 12:09 am
Tested it out, and it works but I have one more feature request.
Make it so before the timer starts it is impossible to pick up the intel.
Make it so before the timer starts it is impossible to pick up the intel.

-
izzy
Head Admin / Co-founder
- Posts: 474
- Joined: Tue Oct 09, 2012 8:16 pm
Who is online
Users browsing this forum: No registered users and 3 guests




