www.main.lv
Don't think just code it

Search results for 'game'

2011-03-13 Sauerbraten patching and cheating

sauerbraten is open source first person shooter. Also there is multi player
mode. I like time to time play sauerbraten. But I am not very good player.

As game source is comes with game you can view it and add some patches that
can help get better scores in games. Usually it called cheating.
As this features/cheats is made by my self I don't think so. But in game admins
don't care =] about it.

First of all this patches don't make game enjoyable for other players
that way sooner or later you will be banned. Every one have freedom to
be banned.

First "allowed" cheat is recoil to 0 from any weapon

in file src/fpsgame/game.h on line 333:   

static const struct guninfo { short sound, attackdelay, damage, projspeed, part, kickamount, range; const char *name, *file; } guns[NUMGUNS] = 
 { 
 { S_PUNCH1, 250, 50, 0, 0, 0, 14, "fist", "fist" }, 
 { S_SG, 1400, 10, 0, 0, 20, 1024, "shotgun", "shotg" }, // *SGRAYS 
 { S_CG, 100, 30, 0, 0, 7, 1024, "chaingun", "chaing"}, 
 { S_RLFIRE, 800, 120, 80, 0, 10, 1024, "rocketlauncher", "rocket"}, 
 { S_RIFLE, 1500, 100, 0, 0, 30, 2048, "rifle", "rifle" }, 
 { S_FLAUNCH, 500, 75, 80, 0, 10, 1024, "grenadelauncher", "gl" }, 
 { S_PISTOL, 500, 25, 0, 0, 7, 1024, "pistol", "pistol" }, 
 { S_FLAUNCH, 200, 20, 50, PART_FIREBALL1, 1, 1024, "fireball", NULL }, 
 { S_ICEBALL, 200, 40, 30, PART_FIREBALL2, 1, 1024, "iceball", NULL }, 
 { S_SLIMEBALL, 200, 30, 160, PART_FIREBALL3, 1, 1024, "slimeball", NULL }, 
 { S_PIGR1, 250, 50, 0, 0, 1, 12, "bite", NULL }, 
 { -1, 0, 120, 0, 0, 0, 0, "barrel", NULL } 
 };

changing sixths values all to 0 makes no recoil.
but if you change recoil to 1024 you can easily jump on the sky after shut.
Think what will see your on-line opponents? Someone if shutting from the skies. 

Not-flying rocket? Yes you can make it.
fourth field in structure is projspeed change it for rocket launcher to
0 and you can place your rockets on air. Bet I don't know what see others.
Only thing with that you will get ban for team-killing because team mates
are usually around you and they blow-up when colliding with rockets in air.

Precision also is very nice but every one will notice that you shutting with shotgun
and chain-gun with precision like rifle.
In src/fpsgame/weapon.cpp on 130 line:  
void offsetray(const vec &from, const vec &to, int spread, float range, vec &dest) 
   { 
       float f = to.dist(from)*spread/1000; 
       for(;;) 
       { 
           #define RNDD rnd(101)-50 
           vec v(RNDD, RNDD, RNDD); 
           if(v.magnitude()>50) continue; 
           v.mul(f); 
           v.z /= 2; 
           dest = to; 
           dest.add(v); 
           vec dir = dest; 
           dir.sub(from); 
           dir.normalize(); 
           raycubepos(from, dir, dest, range, RAY_CLIPMAT|RAY_ALPHAPOLY); 
           return; 
       } 
   } 
make
#define RNDD rnd(2)-1 

and it will work fine.

Remember this patches is cheat/like and it is not good to play with others
when this patches is added because they loose their enjoyment of game. Remember of FREEDOM to be banned.

2011-03-12 Python web login tips

Some times there is need to automitize all tasks.
Like login on page download some info and go out.
There is html parsers they can do such tasks

For example it can be login script for some browser game or mail account that doesnt allow
SMTP or SMTP is not for free.

For example there is web-browser game travian an it after some time playing
it becomes very boring to play because only thing that you do it waiting
while some game events take too many time. Like when you click upgdade
something than you need to wait some hours until finish.

Now here we will make login example.
We need external libraries:
httplib2 http://code.google.com/p/httplib2/
lxml http://lxml.de/

First thing that we need its to get page source.

conn = httplib2.Http("cache")
resp,cont = conn.request("http://travian.com")


After we have source we look on login form
<form method="post" name="snd" action="dorf1.php">
	<input class="text" type="text" name="name" value="">
	<input class="text" type="password" name="password" value="" maxlength="20">
	<input type="image" value="login" name="s1" onclick="xy();" id="btn_login" class="dynamic_img">
	<input type="hidden" name="w" value="">
	<input type="hidden" name="login" value="1299937743">
</form>

 As we see here is many inputs

As ther is only 1 form we dont check and simply take first form from array

from lxml.html import parse,tostring,fromstring,submit_form

page = fromstring( cont )
form = page.forms[0] 
for inp in form.inputs:
	if inp.type == "text":
		inp.value = name
	if inp.type == "password":
		inp.value = password



Dont forget about method="post"

headers = {'Content-type': 'application/x-www-form-urlencoded'}


Now we are ready to send data and get cookie that will allow us
get inside the page

resp , cont = self.conn.request( self.server+"/"+form.action , "POST" , body=urllib.urlencode(body) , headers=headers )


Response has cookie that we need to save if would like to work with page in future

cookie = resp['set-cookie']


Also cookie is needed if whant to logout:

headers = { 'Content-type': 'application/x-www-form-urlencoded' }
headers = { 'Cookie': self.cookie }
body = {}
resp,cont = self.conn.request(self.server+"/logout.php", body=urllib.urlencode(body) , headers=headers)


As you see now cookie is inside headers. You should allways place cookie
inside headers if whant to be loged in. Because only cookie that you get at login
says for server that you are loged in and can see what is behind the wall.

Thers is also easy way how to access DOM components
With your favorite browser you can easly get DOM path to prefered tag in HTML source.

tmp = page.xpath("/html//div//div//div//div//p//span")


You can find some tag by class name using find_class()
Or get text content from tag with text_content()

tmp = page.xpath("/html//div//div//div//div//p//span")[2].find_class("none")[0].text_content()


To make your own script that can parse and get info you need only

reguest()
find_class()
text_content()
xpath()
fromstring()


It is very easy. Now you know everything to make your first script that can login on
you favorite page.

2010-11-18 Scan memory for variable


Somedays ago I was playing one game. And as I not so often playing games. I would like to change some variables in memory like ammo quantity or health. May be it is not very interesting to play game with "cheating" but there is much more interest to play with program.
In such play can help scanmem
Here is example of programm that will help us to lern how to use scanmem:

#include <stdio.h>
#include <stdlib.h>

unsigned int secret_dw = 1000; //variable to search
unsigned int tmp;//for input variable


int main()
{
	int i;
	while ( secret_dw != -1 )
	{
		scanf("%u",&tmp);
		printf("secret_dw was %u \n",secret_dw);
		secret_dw = tmp;
		tmp = 0; // This is to prevent from detecting tmp variable position
	}
	printf("\bExit\n");
	return 0;
}
here only two variables one secret_dw for value that we will search and second one tmp to save input. Also tmp will zeroed if not then we will find tmp and secret_dw. compile example with
make
and run
./example
And in paralel run
$ scanmem `pidof example`
scanmem version 0.11
Copyright (C) 2009,2010 Tavis Ormandy, Eli Dupree, WANG Lu
Copyright (C) 2006-2009 Tavis Ormandy
scanmem comes with ABSOLUTELY NO WARRANTY; for details type `show warranty'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show copying' for details.

info: maps file located at /proc/1801/maps opened.
info: 5 suitable regions found.
Please enter current value, or "help" for other commands.
As we searching 4 byte value of uint we defining it by setting up option
0> option scan_data_type int32
Now we ready to start our game. At begining we know our secret_dw value it is 1000 but we will not use it. Type 1 in example
1
secret_dw was 1000 in scanmem
0> 1
info: 01/05 searching  0x8049000 -  0x804a000...........ok
info: 02/05 searching 0xb763d000 - 0xb763e000...........ok
info: 03/05 searching 0xb7787000 - 0xb778a000...........ok
info: 04/05 searching 0xb77a7000 - 0xb77a9000...........ok
info: 05/05 searching 0xbf9d4000 - 0xbf9f5000...........ok
info: we currently have 58 matches.
As we can see 58 matches. WooHoo. Now type '1000'in example
1000
secret_dw was 1 in scanmem
58> 1000
..........info: we currently have 2 matches.
only 2 now scanmem has also many built in commands you can see them when type help. One of them is 'list'. Use it.
2> list
[ 0]            0x8049680, 1000, [I32 ]
[ 1]           0xbf9f2dd8, 1000, [I32 ]
Here is list of matched variables. Number,address,value,size. By adress we see that our variable is with number 0.
2> set 0=999
info: setting *0x8049680 to 0x3e7...
2> list
[ 0]            0x8049680, 1000, [I32 ]
[ 1]           0xbf9f2dd8, 1000, [I32 ]
Now our variable is with value 999. When you type list it may be little bit confusing that values is the same. Go in example
12
secret_dw was 999 Yes. We have changed our variable. Our goal is completed. Scanmem webpage http://taviso.decsystem.org/scanmem.html

Source contains programm outputs and example code.

2010-10-06 LISP city simulator

Here is first LISP programm that I wrote for LISP courses that I am taking in university.Press food ration per day and houses that you whant to build. There is no end in game.You play until food is zero or until write quit. It was challenging to write something in lisp and also very interesting.Forget to mention that it has some bugs.
Source

2010-09-07 Robatik

This is programming game where you have to controll your robots with simple assembler like language. Game is inspired by AutoWars.  Source contains source,small turorial and examples.
Robatik Game

2010-07-26 Snake by wudu

Terminal snake. First project in python by wudu

Author: wudu

Source
Google Code

2010-04-04 PSP programming

Samples:

Color Filled Rectangle

Games

Snake

2010-04-04 PSP snake game

When I saw ost about patapon exploit that worked on PSP FW 6.20 I was happy. I was bought PSP-3004 for programming but i dont know that not always you can programmyour PSP, but now my dream come true
Link
Since exploit relised I started to trying it. Then I compiled everything
that is needed to programm PSP and now I have my own dirty and unfinished
version of PSP snake game. It can be started at this moment only through exploit.
Source

2010-01-16 Math

Different stuff that have some math inside
2D Vector Library

Attractors

Attractor
Lorenz attractor

Fractals

Simple Fractal
Blender Fractal
Blender Towers

Numerical

Simposon integration method

Other

Voronoi
Pascal Triangle

2009-11-12 Python PyGame Tutorial Fullscreen

added new variable tha tcheck in with mode now screen is
fullscreen = False
Used new event type
if event.type == pygame.KEYDOWN:
When pressing key m we making new screen surface in fullscreen mode. If screen is in fuulscreen mode make window.
if event.key == pygame.K_m:		
  if not fullscreen:
    screen = pygame.display.set_mode( (SCREEN_X,SCREEN_Y) , pygame.FULLSCREEN )
    fullscreen = True
  else:
    screen = pygame.display.set_mode( (SCREEN_X,SCREEN_Y) )
    fullscreen = False
Tutorial Source

2009-09-23 Python Pygame Tutorial Randomnes

All boxes moving with same speed in same directions and all boxes have same size and colorMake changes step by step to see result

self.dx = randint(1,BOX_SPEED)
self.dy = randint(1,BOX_SPEED)
and boxes now moving all seperatly at diferent directions.
self.boxes.append( Box( i*2 , i*2 , randint(BOX_MIN_SIZE,BOX_MAX_SIZE) ,
(i,0,0) ) 
now boxes have diferent sizes
Tutorial source

2009-09-23 Python Pygame Tutorial Boxes Move

New class boxes handles many boxes. Number of boxes depends on cpnstant MAX_BOXES.

MAX_BOXES = 100
and all class Boxes methods is the same only diference is that it handles many boxes.Tutorial Source

2009-09-23 PyGame Lorenz attractor

Here is Lorenz attractor whery popular attractor i have used basic coloring tehnique.
Script
PovRay source

2009-09-15 Python Pygame Tutorial Box Move

added constants that helps controlling screen size

SCREEN_X = 500
SCREEN_Y = 500
BOX_SIZE = 20
BOX_SPEED = 1
box have speed by axis
self.dx = BOX_SPEED
self.dy = BOX_SPEE
detecting if given rect is inside screen borders or not if not then change it direction
def move( self ):
        if self.rect.left+BOX_SIZE > SCREEN_X:
            self.dx = -BOX_SPEED
        if self.rect.left < 0:
            self.dx = BOX_SPEED
        if self.rect.top+BOX_SIZE > SCREEN_Y:
            self.dy = -BOX_SPEED
        if self.rect.top < 0:
            self.dy = BOX_SPEED
        self.rect.left += self.dx
        self.rect.top += self.dy
after few line of code where added box move inside given screen and coalide with screen borders
Tutorial Source

2009-09-07 Python PyGame Tutorial Box Object

There is new object Box. We can draw, mask and move it.Once you init it you can use it with simple interface

box = Box( position_x , position_y , size ,
(color_red,color_green,color_blue,color_alpha) )
moving box to new position. new position calculates x_new = x_old + x
box.move( add_x , add_y )
drawes box on the screen
box.draw()
draw black box on the screen
box.mask()

Tutorial Source

2009-08-31 Python PyGame Tutorial Image Loading

Draw some image and make for it

surface image = pygame.image.load("image_name.format") 

then copy image surface to screen
surface. screen.blit( source_surface , (position_x,position_y) )

Tutorial source

2009-08-23 Python PyGame Tutorial Event System

Now you can set application window. But there is one problem you have to terminate application by killing.
Adding event handling help us exit from application by clicking close button or pressing some other button.

for event in pygame.event.get():
if event.type == pygame.QUIT:
    runing = False

Now you can exit from application by clicking close button.
Event types
There are defined other event types pygame.(KEYUP, KEYDOWN, MOUSEMOTION, MOUSEBUTTONP, MOUSEBUTTONDOWN, VIDEORESIZE). All of these events described in pygame documentation
Tutorial source

2009-08-23 Python PyGame Tutorial Display Setting

First application and we opening window

screen = pygame.display.set_mode( (width_of_window ,height_of_window ) )

In future we will use screen for drawing.
Also there possible make full screen with value pygame.FULLSCREEN
it looks like:
pygame.display.set_mode( (width,height), pygame.FULLSCREEN )


Tutorial Source

2009-08-23 Python PyGame Tutorial

Python Pygame tutorial. This tutorial goal show how to make small and simple pygame pythone script that include all that is need for bigger application. Every tutorial part add only few new lines of code.
Moving Boxes
Goal
Make featured applications with boxes that coaliding one with another.
1. [Set Display]
2. [Event Sytem]
3. [Image loading]
4. [Box object]
5. [Box move]
6. [Boxes move]
7. [Randomnes]
8. [Fullscreen]

2009-05-07 PyGame Attractors

I have found old article about attractors that is resoult what I have done with playing with attractor values. Attractor formula is very simple but result is interesting.

« Previous 12