Author Topic: PerroRACE 2.0 - very cool Racing script  (Read 16924 times)

0 Members and 1 Guest are viewing this topic.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
PerroRACE 2.0 - very cool Racing script
« on: October 05, 2007, 03:00:48 am »
Script Name: PerroRACE
Script Description: Makes a racing gamemode.
Original Author(s): PerroAZUL
Core Version: 2.6.3

Do you like running in soldat? I do.

So here you got something cool. I still want to add a few things, but I think it works. I haven't tested it with more than one player because my connection has been really feckty lately, so some bug may appear.

I won't post the code because it's long, but I'll explain a bit of what it does. Basically, you have a bunch of checkpoints (which are saved in race.ini), and you have to run to the next checkpoint. It will measure your time and tell you if you improved your time (relative to your best). In order to begin the race, all players must be alive and with no movement, if not it won't start.

I tweaked some default maps to test this. I guess I'll add more maps later.

You have some commands:
Quote
/startrace: force a race to start
/endrace: force a race to end
/autostart: change autostart mode (on by default)
/laps #: set number of laps
/loadmap: load map from ini (it's done automatically, use it if you modified the ini)
/savemap: will save the checkpoints and lap to a ini file (not race.ini cuz WriteFile not working good)
/showpoints: lists the checkpoints in the console (for debugging)
/setnumpoints: sets the number of checkpoints in the map (use before /pos)
/pos: takes your player position and saves it in the 'current checkpoint', then it increases current checkpoint by 1
/setpoint #: sets the current checkpoint

If you want to add a map, do this (in-game):
0- /autostart (disable it cause it can get annoying)
1- stand on the first checkpoint (which should be in the spawn position)
2- /setnumpoints # (set it to the number of checkpoints in the map)
3- /setpoint 1 (to make sure)
4- /pos
5- go to next checkpoint
6- if there are more checkpoints go to step 4
7- /laps # (set it to whatever you want to be the default lap count for the map)
8- /savemap
9- raplace race.ini with the new created race#.ini

So i got tired of writing already. I'll post some screenshots.






So, here the thing is attached. Download it and test it! It can be a lot of fun! Do it! Do it!

Suggestions for the server configuration:
 * No weapons.
 * No respawn time (0)
 * Deathmatch gamemode.



Updated to 1.1 (13-11-07): <- Removed because it was more buggy
 * Implemented a bug recovering method (for the ThreadFunc bugs).
 * Changed Sleep(1) to Sleep(20) to improve performance.
 * May have changed something else and I don't remember.
 * The ZIP now contains all the maps added so far.

Updated to 2.0 (23-11-07):
 * Completely re-writen script.
 * Uses AppOnIdle instead of ThreadFunc.
 * race.ini moved to ./scripts/perrorace/race.ini

Updated to 2.1 (14-03-08):
 * Should work on CTF or any game mode.
« Last Edit: March 14, 2008, 06:32:42 pm by PerroAZUL »
urraka

Offline SirJamesaford

  • Flagrunner
  • ****
  • Posts: 763
  • SirJamesaford is still in the early Beta stage.
Re: PerroRACE - very cool Racing script (beta?)
« Reply #1 on: October 05, 2007, 03:18:45 am »
Dude...Id love to try this...it looks pretty fun.
And if the dam breaks open many years too soon
And if there is no room upon the hill
And if your head explodes with dark forebodings too
Ill see you on the dark side of the moon

Offline Kagesha

  • Flagrunner
  • ****
  • Posts: 702
  • cunts
Re: PerroRACE - very cool Racing script (beta?)
« Reply #2 on: October 05, 2007, 04:31:10 am »
Hahahah this looks kinda fun FOOTRACING TIME!!!!!
Can't wait till it actually comes out on a server!

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: PerroRACE - very cool Racing script (beta?)
« Reply #3 on: October 05, 2007, 07:37:19 am »
hahaha cool
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline bulgaria

  • Major(1)
  • Posts: 5
Re: PerroRACE - very cool Racing script (beta?)
« Reply #4 on: October 05, 2007, 08:04:08 am »
thanks race hehe

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #5 on: October 05, 2007, 12:11:54 pm »
I'm running it on my PC now. Feel free to enter and try, but keep in mind it may be laggy as hell beause it's a home connection and my brother has been using a lot of the bandwidth ¬¬

ip: perroazul.dyndns.org
port: 23074

I suggest you download the maps before joining because my upload speed sucks.
urraka

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: PerroRACE - very cool Racing script (beta?)
« Reply #6 on: October 05, 2007, 12:36:12 pm »
I tried setting up a server of this just now (on Linux), and I couldn't get it working properly; probably due to the general instability known as ThreadFunc.

Code: [Select]
Waiting for everyone to be alive and with no movement.
Starting in 3...
Starting in 2...
Starting in 1...
Race Started!
 [*] [Error] PerroRACE -> (AppOnIdle): Out of Global Vars range
 [*] [Error] PerroRACE -> (RaceLoop): Access violation at address 0809DA07, accessing address 00000109
 [*] [Error] PerroRACE -> (AppOnIdle): Access violation at address 0809DA90, accessing address 00000109
 [*] [Error] PerroRACE -> (AppOnIdle): Access violation at address 0809DA90, accessing address 0000011C
 [*] [Error] PerroRACE -> (AppOnIdle): Access violation at address 0809DA90, accessing address 0000012C
(etc)

Would you think there's any way for you to rewrite it into only using AppOnIdle instead of threading it? I know it's quite a bit to ask for, and I know it isn't your fault that ThreadFunc is flipping out all the time - but it'd most likely increase the stability of the script by heaps. I might give it a look myself if I get enough free time.

Great work anyhow, and good luck with any future endeavours. :)

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #7 on: October 05, 2007, 01:04:42 pm »
It's impossible to write it on AppOnIdle the way I did it because it has accuracy of milliseconds, and also some checkpoints might not be detected with AppOnIdle because you can run through them in less than a second. I don't know if there is a way to fix that. Maybe passing all the variables by reference to the ThreadFunc could work, I don't know. I don't really understand the deal with ThreadFunc. It works great for windows.
If I can think of any workaround I'll do it.
urraka

Offline Aquarius

  • Soldier
  • **
  • Posts: 234
Re: PerroRACE - very cool Racing script (beta?)
« Reply #8 on: October 05, 2007, 01:37:00 pm »
You can do something like this in AppOnIdle: the checkpoints should be made of 2 points - the points will create a line segment. 2 player positions, from previous AppOnIdle and current AppOnIdle, will create the second line segment. Check if the line segments intersect, if true, the player passed the checkpoint. Though I dunno if it won't be to slow.
« Last Edit: October 05, 2007, 01:43:59 pm by Aquarius »

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #9 on: October 05, 2007, 01:42:14 pm »
The way it's done it detects a square of 120x120. I guess I could make it bigger, but i don't like the inaccuracy. Also, I use milliseconds to measure the time you get to each checkpoint, and you can tell if you went faster or not reading a message like "Checkpoint 2 - 02.12 (-00.50)". That means you took 2.12 seconds to get to the checkpoint 2 from the starting position, and you got there 0.5 seconds faster than your best time.

The server I posted didn't have map downloading activated. Sorry, i fixed it now.
urraka

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: PerroRACE - very cool Racing script (beta?)
« Reply #10 on: October 05, 2007, 02:48:53 pm »
Nice nice! Sounds great!
I hope somebody hosts this soon on a non-home computer on some dedicated server so I can play this soon :P
*wants to play* so if u do, wanna post the ip/port here pretty please?

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #11 on: October 05, 2007, 08:29:08 pm »
Well today I played it on my server with some people. It's really fun :D. (Ok, i have to say it, that face is really gay)

I'll explain some more details about the script here.

When you join the game and there are some players racing (meaning the race has started already), you have to wait until the curent race ends. In the meanwhile you can run around.

When you complete all the laps, you have to wait for the other players to complete the laps too. When everyone completes all the laps the race has officially ended and a message with the positions will appear.

After the race ends, it will automatically start again in a matter of seconds (if /autostart is activated). A message will appear "Waiting for all players to be alive and with no movement". That means that the script waits for all the players to be ready before starting the race. You don't have to go to the start position. After everyone is still the game will be paused and you will see a countdown in the top. (starting in 3... 2... 1... GO). When the game gets unpaused all the players will appear in the starting position. I will try to make it take the players to the starting position before the game gets paused later.

When you reach a checkpoint (you have to run nearby the checkpoint sign, if you run far from it, it won't be detected), a message Checkpoint # will appear. On the top you will see a message "Checkpoint # - <number1> (+/-<number2>)". The first number is the time it took you get to that checkpoint, relative to the starting position. The seconds number is the difference between that time and the best you've done to that checkpoint. If it's negative you improved, if it's positive you went slower.

If you die in the middle of a race, you should appear in the last checkpoint you crossed. I think there is a bug with this, which happens when you go out of the map bounds.
« Last Edit: October 05, 2007, 08:30:43 pm by PerroAZUL »
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #12 on: October 27, 2007, 11:27:41 pm »
sounds great, ill download it if I can run it and play on one computer
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: PerroRACE - very cool Racing script (beta?)
« Reply #13 on: October 28, 2007, 12:14:54 pm »
NiCe WoRk mate. This is cool. But can you turn off this script in game whenever u want? I only got my clan server so i don't want to test it there so i want to make sure that i don't need to delete it when i don't want to race... Do u get me or i made it complicated :P ?

EDIT: Ehh i wold really like to play this but my server is braking when i run it...
« Last Edit: October 28, 2007, 12:26:26 pm by Norbo »

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #14 on: October 28, 2007, 02:00:43 pm »
If your server is running on Linux I'm afraid you won't be able to use it, because of the ThreadFunc thing. On windows it seems to work fine, with some random bugs sometimes but not very frequent.
You can use the command /autostart to disable the race starting automatically. If the race doesn't start it won't interfiere with the game.
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #15 on: October 29, 2007, 09:59:24 pm »
Ive just been on a server called Perro race and a few people also joined but there was no races and none of us knew how to start one?

So how do you start a race?
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #16 on: October 30, 2007, 10:04:19 pm »
Heh, the race is supposed to autostart, but currently this script is unstable because of 2 reasons:
1. The ThreadFunc thing, which causes errors but I think i can manage to handle them and make it restart the race.
2. The "Couldn't load map lalal" bug, which happens all the time, and when this happens the script doesn't work anymore at all.

Anyway, if anyone finds and joins my race server, write !admin, if i'm here (which is highly probable) i'll see the message and probably join to race :p
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #17 on: November 01, 2007, 10:16:11 pm »
How do I install this script on my home computer for me to play by my self?

I saw on one of avarax's script threads that i need to put it in a folder calles 'Soldat server' but I don't have one. Is there a program I need to install?

I thought I might be able to run scripts by running a dedicated server then starting up soldat and finding it in 'Join game' and it worked, but I don't know how to install scripts. Help.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #18 on: November 02, 2007, 12:28:28 am »
First of all you must download the dedicated server, which you can downlaod >here< (it's not the one that comes with soldat)

Then, you unzip that somewhere and unzip PerroRACE.zip in the same somewhere.

You can edit the file soldat.ini to set the server options, but it's not really necessary.

If the race won't start use the command "/recompile race". That will reload the script. Other than that use the commands I posted in the first post. Remember that you have to use some of the maps I included (rc_Airpirates, rc_Bigfalls, rc_Arena) or set the checkpoints on your own if you want to play in another map.
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #19 on: November 03, 2007, 04:14:33 pm »
Oh ok.

I thought the dedicated server that came with soldat was the right one.

Now there will be even more new ways to play soldat, and right now i'm trying to learn scripting :)

Date Posted: November 02, 2007, 02:34:48 pm
I got another question and something to say:

Firstly: When I try play your race by mysef on my computer, Autostart doesn't start races automatically and when I force a race it pauses and counts down, But when it says 'go' Immediatly it says 'Race ended!' and 'Positions:' , I can run into  the checkpoints and nothing happens :P

Secondly:
When I was playing on your server in the Bigfalls map I noticed that the first checkpoint is actuall near the first one you see when you start running, not the very left uppermost one.
This is making it like a double checkpoint and the arrows don't poit to it.
Is it supposedto be like this, or is it a checkpoint error?
« Last Edit: November 03, 2007, 04:20:35 pm by chutem »
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #20 on: November 04, 2007, 02:08:36 pm »
About the second, yeah, I messed up with the arrows, it's a double checkpoint. Not a problem once you know the circuit.

About the first, were you playing in the server when you attemped to start the race? If there are no players the race will automatically end. Also, the autostart won't start any race if the server is empty.

So, you have to do this:
1. Join the server.
2. Wait for the message "Waiting for all players to be alive and with no movement.".
3. Stay still for a little while (this is to avoid the initial speed after moving all players to the initial position).
4. Wait for th countdown and start running.

If it doesn't work that way it's because of the inestability of ThreadFunc, so try restarting with "/recompile race" until it works.
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #21 on: November 06, 2007, 02:23:21 am »
Hmm it seems to be working now, but i don't know why, maybe because I changed the gamestyle to '1', or possibly that i set max grenades to 4000 :)

Anywho its a great script and I might just make some maps for it :D
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #22 on: November 06, 2007, 02:24:07 pm »
Cool, if you make more maps post them here :P (remember to include the checkpoints stored in race.ini)
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #23 on: November 08, 2007, 09:55:04 pm »
Heres my first map, rc_Blox, I'll make more over weekend.

Checkpoints:


[rc_Blox]
Laps=5
Num=8
checkpoint1=28.87,-745.29
checkpoint2=359.89,-234.46
checkpoint3=83.64,54.95
checkpoint4=-285.95,282.88
checkpoint5=95.62,449.97
checkpoint6=426.46,5.85
checkpoint7=-184.27,-247.64
checkpoint8=-483.7,-235.16


\/ Map \/
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #24 on: November 09, 2007, 01:59:32 pm »
Nice man, already added it to my server :P

I'll post tow more maps a friend made.

[rc_HH]
Laps=3
Num=9
checkpoint1=-947.79,-644.57
checkpoint2=-991.79,-457.95
checkpoint3=-921.07,0.23
checkpoint4=-715.9,-260.39
checkpoint5=186.2,227.04
checkpoint6=1049.67,625.89
checkpoint7=1330.51,311.44
checkpoint8=1056.9,18.55
checkpoint9=-40.66,-134.94

[rc_cambodia]
Laps=3
Num=10
checkpoint1=-505.7,-668.35
checkpoint2=-802.82,-179.74
checkpoint3=-233.23,540.54
checkpoint4=-356.85,640.57
checkpoint5=96.2,528.22
checkpoint6=481.43,579.57
checkpoint7=393.61,161.32
checkpoint8=88.97,-4.1
checkpoint9=441.9,-386.66
checkpoint10=268.42,-747.82
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #25 on: November 11, 2007, 02:06:39 am »
three more maps, i don't know wat happened to the checkpoints for conquest, but i can't be bothered making another zip file. Or do the checkpoints right now :P

Checkpoints:


[rc_Ash]
Laps=3
Num=11
checkpoint1=-1068.13,177.26
checkpoint2=-421.63,-105.29
checkpoint3=181.66,159.15
checkpoint4=241.36,-105.61
checkpoint5=-181.71,158.24
checkpoint6=-557.91,82.12
checkpoint7=-174.96,367.99
checkpoint8=553.27,82.63
checkpoint9=172.27,-226.36
checkpoint10=-363,-299.94
checkpoint11=-661.17,339.55

[rc_Cobra]
Laps=3
Num=9
checkpoint1=-18.87,420.57
checkpoint2=-811.33,-59.88
checkpoint3=-216.57,204.99
checkpoint4=-576.68,-60.92
checkpoint5=-392.31,-257.41
checkpoint6=375.21,-245.38
checkpoint7=582.77,-60.9
checkpoint8=196.56,203.88
checkpoint9=813.72,-60.9
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #26 on: November 11, 2007, 07:15:17 pm »
I made the checkpoints for rc_Conquest

[rc_Conquest]
Laps=3
Num=12
checkpoint1=-2019.18,155.06
checkpoint2=-1375.49,536.11
checkpoint3=-17.39,521
checkpoint4=20.32,-91.89
checkpoint5=444.28,199.34
checkpoint6=1058.35,369.19
checkpoint7=2159.59,284.29
checkpoint8=767.23,531.06
checkpoint9=456.3,-28.91
checkpoint10=20.32,-91.89
checkpoint11=-451.71,-30.42
checkpoint12=-1904.73,384.15


By the way, I really liked how you made those 3 maps :)
« Last Edit: November 11, 2007, 07:20:54 pm by PerroAZUL »
urraka

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: PerroRACE - very cool Racing script (beta?)
« Reply #27 on: November 12, 2007, 08:20:33 am »
Nice script but when I tested it at my linux server it was jumping to 54% of CPU usage with 2 players. Any idea why ?

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #28 on: November 12, 2007, 11:31:54 pm »
Hmm I never took a look at the CPU usage, but I used Sleep(1) in the thread loop. Should I use Sleep(x) with x > 1? Anyway, I'll update the script soon, I have a couple of ideas to handle the threadfunc bugs. But keep in mind that it's not a stable script.

Date Posted: 12/11/2007 - 11:07:08
Well I updated the script.

I changed the Sleep(1) in the loops to Sleep(20), that might help with the performance. Please test it and tell me how it goes.

I also implemented a way to handle the bugs but I'm not so sure if it works because I couldn't test it since the ThreadFunc didn't want to crash this time ¬¬. Maybe having Sleep(20) reduced the probability of crashing. (I've just made that up :P)
So the thread should be recovered every second if it crashed, in theory.

Let me know if something goes wrong, I'll test it more carefully later.

The new package contains all the maps posted here so far.

Download

edit: tested it for a while and nothing worked as expected ¬¬... working on it...
« Last Edit: November 13, 2007, 09:49:26 am by PerroAZUL »
urraka

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: PerroRACE - very cool Racing script (beta?)
« Reply #29 on: November 13, 2007, 01:45:14 pm »
You can do something like this in AppOnIdle: the checkpoints should be made of 2 points - the points will create a line segment. 2 player positions, from previous AppOnIdle and current AppOnIdle, will create the second line segment. Check if the line segments intersect, if true, the player passed the checkpoint. Though I dunno if it won't be to slow.
I'm afraid that is not a solution to the time resolution problem as shown in this picture:


Let's assume the player moves from position one to two between two consecutive calls of AppOnIdle. Due to the large timestep it would miss the checkpoint in that case. Let me know if I misunderstood your idea.

PerroAZUL, you can increase the time resolution if you don't need weapons! If you drop a weapon at each checkpoint, you can do the distance checking and whatnot in onWeaponChange. Also, immediately Forceweapon fists again in the routine to make sure it gets called again the next checkpoint. Of course, you also need to drop a new weapon, but this shouldn't be much of a problem. To be on the safe side you could drop multiple weapons just in case players arrive at a checkpoint at the same time. If I'm right about this, this would eliminate the need for threadfunc and get rid of your problems. :)

Another (less elegant) option would be to have a bot on an offscreen section of the map on hurtpoly's and doing the distance checking in onplayerkill. You can then set your desired time resolution by changing the amount of damage done by the hurt poly's. Of course, respawntime should be zero then and I'm not sure if that is possible. I reckon this option could induce quite some lag on your server though, so I'd try the former first.
« Last Edit: November 13, 2007, 02:25:01 pm by sai`ke »
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #30 on: November 13, 2007, 02:42:53 pm »
Well right now I'm rewriting the code, making it clean cause it was a mess. I'll try how it works doing the loop in AppOnIdle without considering the time resolution. Maybe it's not so bad, the problem comes when 2 or more players go together, the one with lower ID will win I guess. And also I made this script having in mind making it save the best lap times, and 1 second resolution would suck for that.

The weapons idea would screw up the race because sometimes you have to stop in order to take the weapon, and also there are some checkpoints in the air.

Thinking about that line thing, another idea came to my mind. I make a line from the player position to the next checkpoint in one call to AppOnIdle, in the next I do the same. Then I calculate the angle between those 2 lines, if it's greater than 90° it means you crossed the checkpoint. I still have to think about it, I'm not so sure about this :P

PD: Is there even a way to calculate the angle... sh*t!
« Last Edit: November 13, 2007, 02:45:34 pm by PerroAZUL »
urraka

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: PerroRACE - very cool Racing script (beta?)
« Reply #31 on: November 13, 2007, 03:05:36 pm »
Quote
Well right now I'm rewriting the code, making it clean cause it was a mess. I'll try how it works doing the loop in AppOnIdle without considering the time resolution.
Looping in appOnIdle will pause your server and probably cause a truckload of other problems. I'll assume you mean just checking in apponidle. Furthermore, a time resolution of a second is pretty bad for racing.

Quote
Maybe it's not so bad, the problem comes when 2 or more players go together, the one with lower ID will win I guess.
Why would this be a problem? You just loop through all players and check whether they are close enough.

Quote
And also I made this script having in mind making it save the best lap times, and 1 second resolution would suck for that.
Yeah.

Quote
The weapons idea would screw up the race because sometimes you have to stop in order to take the weapon, and also there are some checkpoints in the air.
I don't think you need to stop to pick up a weapon if you currently have no weapons. It wouldn't solve the in air checkpoint problem though but can't you move these, or change the maps a little so that there is a plateau for the weapons to fall on?

Quote
Then I calculate the angle between those 2 lines, if it's greater than 90° it means you crossed the checkpoint. I still have to think about it, I'm not so sure about this
Nope. That won't hold. It's not very hard to come up with a counterexample.

There is no substitute for time resolution when it comes to racing I'm afraid.

Also, ok, if the weapons thing isn't an option, consider putting a bot somewhere, spawn bullets above him at different heights and doing the distance checking in OnPlayerDamage. I'm not sure if there's a built-in time routine that gives you the current time with a resolution of less than a second but if it's a big problem you could always set up a secondary program that continuously writes the current time including milliseconds to a file and read it on passing a checkpoint. Even without that, you'd still know who is first tho'.

P.S. If you still need angles, you can calculate the angle between two vectors by means of the dot product.
Consider two vectors v1 and v2 then
v1x * v2x + v1y * v2y = cos( angle between them ) * length( v1 ) * length( v2 )
with length I mean geometric length and not number of elements.


Date Posted: November 13, 2007, 02:55:54 pm
Here you go:
Code: [Select]
function angle( v1x, v1y, v2x, v2y: single ): single;
var
cosangle: single;
dist: single;
begin
dist := ( distance( 0, 0, v1x, v1y ) * distance( 0, 0, v2x, v2y ) );
cosangle := ( v1x * v2x + v1y * v2y ) / dist;
if dist = 0 then
begin
result := -1;
exit;
end
result := 90 - 720 * ( arctan( cosangle / ( 1 + sqrt( 1 - cosangle * cosangle ) ) ) ) / (2 * pi);
end;

PS. Note that this will always give you the smallest angle between two vectors!
« Last Edit: November 13, 2007, 04:08:54 pm by sai`ke »
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #32 on: November 13, 2007, 03:31:16 pm »
1. Yes I meant just checking in AppOnIdle :P

2. I meant that considering using the time resolution of 1 second. If both player are too close and reach the final checkpoint, the server will think they reached it at the same time. So as that's checked looping through all players, the one looped first will be the winner.

3. Yep.

4. I don't say you need to stop every time, but many times I've have the problem that I want to pick up a weapon and it takes a little while to pick it up. Usually with the knife, maybe because it's small (?). Anyway, making all the checkpoints in ground limits the map layouts and that sucks too :P

5. So far I couldn't think of a counter example. The only problem I found is for example if you are going straight down to a checkpoint in the ground and then need to turn 90°, if the point is too close to the ground and the player never gets to cross it the angle won't be greater than 90°. But that can be solved not placing the point too close to the ground. And also the same checking the script does right now would be done apart from this. In the worst case you'll have to stay 1 second in the checkpoint. I know it sucks, but I'd like to make a stable script and see how bad it is. I will also make the threaded version, which works perfectly for me, with some exceptions :P

6. About the angle calculating, yeah I knew there was some formula for that, what I was thinking was whether I would have the needed functions, in this case arctan. I just don't know if it exists in the engine, it doesn't appear in EnEsCe manual.

He should really implement those timers :P

PD: :P
urraka

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: PerroRACE - very cool Racing script (beta?)
« Reply #33 on: November 13, 2007, 03:35:16 pm »
note I made a typo in the previous version of that angle thing, so you might wanna c/p it again ;)
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #34 on: November 13, 2007, 03:37:44 pm »
No problem, I'm not coding that part yet :P
urraka

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: PerroRACE - very cool Racing script (beta?)
« Reply #35 on: November 14, 2007, 07:02:04 am »
The problem with a small checking range is that if people need to wait they need to wait unequal amounts of time, which makes it unfair.  The problem with a large checking range is that people can short circuit the 'race track'.
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline D!m000n

  • Major(1)
  • Posts: 11
Re: PerroRACE - very cool Racing script (beta?)
« Reply #36 on: November 16, 2007, 08:19:19 am »
How do i start the race in my own server?
after i open some of race maps ;o

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE - very cool Racing script (beta?)
« Reply #37 on: November 16, 2007, 12:23:46 pm »
First of all you must download the dedicated server, which you can downlaod >here< (it's not the one that comes with soldat)

Then, you unzip that somewhere and unzip PerroRACE.zip in the same somewhere.

You can edit the file soldat.ini to set the server options, but it's not really necessary.

If the race won't start use the command "/recompile race". That will reload the script. Other than that use the commands I posted in the first post. Remember that you have to use some of the maps I included (rc_Airpirates, rc_Bigfalls, rc_Arena) or set the checkpoints on your own if you want to play in another map.
urraka

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: PerroRACE - very cool Racing script (beta?)
« Reply #38 on: November 16, 2007, 06:50:24 pm »
in the server.ini, mke sure the gamemode is 0 or 1 and there is no bots, double click dedicated server.

then open up normal soldat > join game and request the local servers, yours should appear join al voila
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Eclipse

  • Soldier
  • **
  • Posts: 210
  • :D
Re: PerroRACE - very cool Racing script (beta?)
« Reply #39 on: November 17, 2007, 02:58:53 am »
I went in, Its okay. Maps are awesome
All teh Piezors Shall beh Minezors!

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #40 on: November 22, 2007, 11:15:48 pm »
Script updated. Doesn't use ThreadFunc anymore (got tired of bugs), so now it has a time resolution of 1 second. It's still fun. If someday something like timers are added to the engine I'll make the script better. The race.ini now is located in ./scripts/perrorace/race.ini. Saving the map doesn't make extra ini's since WriteFile is working fine (I must have done something wrong before). And that's it.
Also, the code is MUCH cleaner than the previous version.

PerroRACE 2.0.zip
urraka

Offline Londonbrig0

  • Major(1)
  • Posts: 38
  • despite my experience, I'm a noob, deal with it
Re: PerroRACE 2.0 - very cool Racing script
« Reply #41 on: December 15, 2007, 12:22:53 am »
wow, very cool, starting to make soldat like all those insane starcraft mods
I could have sworn I had something witty to put here...

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: PerroRACE 2.0 - very cool Racing script
« Reply #42 on: December 15, 2007, 11:07:40 am »
First of all you must download the dedicated server, which you can downlaod >here< (it's not the one that comes with soldat)

Then, you unzip that somewhere and unzip PerroRACE.zip in the same somewhere.

You can edit the file soldat.ini to set the server options, but it's not really necessary.

If the race won't start use the command "/recompile race". That will reload the script. Other than that use the commands I posted in the first post. Remember that you have to use some of the maps I included (rc_Airpirates, rc_Bigfalls, rc_Arena) or set the checkpoints on your own if you want to play in another map.

Done... But how can i join it? Whats the IP etc...
EDIT: Problem solved :) Just playing it! Cool!

Date Posted: December 15, 2007, 09:19:20 am
I dont get how to add maps....

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #43 on: December 15, 2007, 11:08:50 am »
To add your own maps or to add maps to the mapslist?
urraka

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: PerroRACE 2.0 - very cool Racing script
« Reply #44 on: December 15, 2007, 12:23:35 pm »
.... create a map with chekpoints.... does the scenery adds itself or u need to make a map in polyworks? i mean that Checkpoint scenery and the arrorws

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #45 on: December 15, 2007, 02:01:28 pm »
The scenery must be added by a map editor. I can't add scnecery from the script. So use polyworks for that.
urraka

Offline happytodd

  • Major(1)
  • Posts: 48
Re: PerroRACE 2.0 - very cool Racing script
« Reply #46 on: December 28, 2007, 05:34:52 am »
How do you actually set it up? Do you run it as a deathmatch mode?
And where do you put the race file?

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #47 on: December 28, 2007, 12:31:16 pm »
First read this if you haven't: http://forums.soldat.pl/index.php?topic=20940.msg252844#msg252844

And use deathmatch yeah. I also disable all weapons. And set respawn time to zero.
urraka

Offline happytodd

  • Major(1)
  • Posts: 48
Re: PerroRACE 2.0 - very cool Racing script
« Reply #48 on: December 28, 2007, 10:05:34 pm »
Ok Ive set it up all correctly I believe but when I run the server I get this error:

RACE : Can't find map checkpoints.
  • [Error] Perrorance -> <AppOnIdle>: I/O error 103


Anyone know how to solve it :(

Date Posted: December 28, 2007, 09:55:46 pm
I think its because I have the race.ini file in the wrong area. Where do you actually put it. I tried it in the map area. In the scripts and in soldatserver263 directory. This gets abit confusing

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #49 on: December 29, 2007, 01:27:47 am »
You don't need to move the race.ini file. Try renaming Perrorance to perrorace maybe.
urraka

Offline happytodd

  • Major(1)
  • Posts: 48
Re: PerroRACE 2.0 - very cool Racing script
« Reply #50 on: December 29, 2007, 02:17:06 am »
So where is the race.ini file ment to be located?
I tried renaming perrorance to perrorace but I get the same error.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #51 on: December 29, 2007, 07:01:29 am »
It should be right here: ./scripts/perrorace/race.ini
It may also happen because of a problem with some linux distributions, what OS are you using? If that's the case I'll try to fix the error. I also don't know much about this, but it also could be because of the file not having the proper access rights. It should be readable and writable by the soldatserver. Maybe somebody else with more experience on this can help a bit.
urraka

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: PerroRACE 2.0 - very cool Racing script
« Reply #52 on: December 29, 2007, 07:06:06 am »
File exist does not seem to work on Debian if im right. Check my Nick Registration script aswell..
It works on CentOS - SUSE and windows but failed by 1 person that´s using Debian.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #53 on: December 29, 2007, 07:08:47 am »
Yes, I'm aware of that, but I think my script isn't using FileExists. I'm checking.
urraka

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: PerroRACE 2.0 - very cool Racing script
« Reply #54 on: December 29, 2007, 07:14:03 am »
check if it uses things like readfile <> '' or anything, it gave me this error before I/O Error 103..
Try to use File Exist instead then. Let me know if you found a fix please. Would be nice to have the scripts working on all Distros



Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #55 on: December 29, 2007, 07:21:35 am »
I've just checked and this scripts doesn't check for file existence at all, so it must something with access rights.
urraka

Offline happytodd

  • Major(1)
  • Posts: 48
Re: PerroRACE 2.0 - very cool Racing script
« Reply #56 on: December 29, 2007, 08:39:30 am »
Ok now Im just getting this error

RACE: Cant find map checkpoints.

And thats pretty much it no 103 error etc. Its all set up like its ment too..

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #57 on: December 29, 2007, 12:16:57 pm »
Well, that means you are playing on a map that doesn't have checkpoints. You should play in the maps attached in the first post.
urraka

Offline happytodd

  • Major(1)
  • Posts: 48
Re: PerroRACE 2.0 - very cool Racing script
« Reply #58 on: December 29, 2007, 09:41:23 pm »
Yes thanks so much its all working now.
Now I need to try fix my ports up etc so I can actually host it for Australians :D
It seems like you've done a great job!

Offline Szewczuq

  • Soldier
  • **
  • Posts: 115
  • WOOH! ROCKS ON MY HEAD!
    • POLISH GAMERS COMMUNITY
Re: PerroRACE 2.0 - very cool Racing script
« Reply #59 on: December 30, 2007, 01:16:11 pm »
haha nice job  PerroAZUL :P can i have ip to sevrer with this script? :D

Date Posted: December 30, 2007, 01:14:16 pm
Perro? maybe u can change this script to Team run (ctf) ect. 2v2 run or 3v3? ;D



Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #60 on: December 30, 2007, 02:43:55 pm »
Well, i don't know how a race would work with teams. Not like I'm going to program something like Formula 1.
urraka

Offline Szewczuq

  • Soldier
  • **
  • Posts: 115
  • WOOH! ROCKS ON MY HEAD!
    • POLISH GAMERS COMMUNITY
Re: PerroRACE 2.0 - very cool Racing script
« Reply #61 on: December 30, 2007, 03:18:00 pm »
hehe i can make map to team run :)

Date Posted: December 30, 2007, 03:16:59 pm
CTF 2v2 or 3v3
when 1 player with team finished run another is starting run :)



Offline happytodd

  • Major(1)
  • Posts: 48
Re: PerroRACE 2.0 - very cool Racing script
« Reply #62 on: December 31, 2007, 09:59:26 am »
I think you should do what you can possibly do here. It would be very very fun and exciting what this racing mod would do. Could possibly be just as good as the volleyball mod.
As I have that said have a happy new year from happytodd

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #63 on: December 31, 2007, 02:00:06 pm »
Well, I might consider adding that "team-racing" when i get some time.
urraka

Offline Szewczuq

  • Soldier
  • **
  • Posts: 115
  • WOOH! ROCKS ON MY HEAD!
    • POLISH GAMERS COMMUNITY
Re: PerroRACE 2.0 - very cool Racing script
« Reply #64 on: December 31, 2007, 02:20:40 pm »
hehe good luck perro :)



Offline happytodd

  • Major(1)
  • Posts: 48
Re: PerroRACE 2.0 - very cool Racing script
« Reply #65 on: January 01, 2008, 03:21:29 am »
Yep goodluck. I would help but I never studied this type of thing :P

Offline miketh2005

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 668
  • What's the URL for www.microsoft.com?
Re: PerroRACE 2.0 - very cool Racing script
« Reply #66 on: January 11, 2008, 02:19:20 pm »
Can I run this with Gamemode=3 ? For CTF because thats where all the people are and some people filter their games for CTF ONLY, so can I run this with CTF with no flags?
Quote from: 'Ando.' pid='12999178' dateline='1309046898'
My new password is secure as shit :)
Mate, I am not sure Shit is even secured nowadays.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: PerroRACE 2.0 - very cool Racing script
« Reply #67 on: January 11, 2008, 07:24:48 pm »
I have no idea, but you could try... I think it should work.
urraka

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: PerroRACE 2.0 - very cool Racing script
« Reply #68 on: September 09, 2010, 05:06:04 am »
keep getting apponidle out of range errors during game, any chance you might fix that?

using version 2.1
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: PerroRACE 2.0 - very cool Racing script
« Reply #69 on: September 11, 2010, 04:52:09 am »
Try fixing it yourself?
If you don't know what Out Of Range is:
Code: (pascal) [Select]
var
  SomeArray: Array [1 .. 2] of byte;

procedure AppOnIdle(Ticks: integer);
begin
  SomeArray[3] := 1;
end;
Throws the Out Of Range error each second.
It comes when you try to access a index which doesn't exist in an array.