Lua request : acceleration zone (for shoppa and techracer)

7 replies [Last post]
sphrix
sphrix's picture
User offline. Last seen 1 day 6 hours ago. Offline
Joined: 2011-04-07
Posts: 203

So,

what if we could have some zone that would act as acceleration zone like in construction mode you have an healing zone.

Imagine you play the last new shoppa map which present some acceleration zone at certain x;y;radius location

You go with your rope/flying saucer/or even walking and jumping, and when you are in this zone your speed rise !

I tried to code it myself, but ... i need someone to either help, either code it completly

I also wonder if it is better as map.lua (mission's map) or to add this in the Mask.png (would need to use one of the few remaining color in mask.png)

Anyway here is what i tried :

if (player ~= nil) then
if (gearIsInBox(player, 0, 0, 4000, 2048) then
SetGearVelocity(player, 150, 150)
end
end

not sure it is the correct function...

I placed it in ongametick ;
i know one of the problem might be the gear UID... currenthedgehog didnt work neither.

If you can and if you like the idea please contribute Smile

the beachs hogs surfin hedgewars

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 36 weeks 4 days ago. Offline
Joined: 2016-06-26
Posts: 363

Weee !!!

I Will make it for you m8 Big Grin
Let me do it :DDD

BUT !
My Only problem in this also ATM is Internet !!!
If i late and someone else make it before me, sorry, its doesn't easy to get it ;/
Hope can help you

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

sphrix
sphrix's picture
User offline. Last seen 1 day 6 hours ago. Offline
Joined: 2011-04-07
Posts: 203

awesome !

No worry about the time Wink Smiley

the beachs hogs surfin hedgewars

sphrix
sphrix's picture
User offline. Last seen 1 day 6 hours ago. Offline
Joined: 2011-04-07
Posts: 203

so, little update,

Nemo helped me and now it is working,

i still have some adjustemnt to do but it is in a good way, here it is in case you are interested :

include this at the beginning : HedgewarsScriptLoad("/Scripts/Utils.lua")

and then include this :

function onGameTick20()

if CurrentHedgehog ~= nil then
dx, dy = GetGearVelocity(CurrentHedgehog)
if (gearIsInBox(CurrentHedgehog, 1, 1, 4000, 2000)) then
SetGearVelocity(CurrentHedgehog, dx*2, dy*2) --ultra speed ! careful !
end
end
end

edit : result : http://i.imgur.com/o3x7Wvy.gifv

the beachs hogs surfin hedgewars

nemo
nemo's picture
User is online Online
Joined: 2009-01-28
Posts: 1704

For the record, I did recommend adding ±10 to dx for a speed booster, not doubling speed every 20ms ☺

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 36 weeks 4 days ago. Offline
Joined: 2016-06-26
Posts: 363

sphrix allegedly wrote:

so, little update,

Nemo helped me and now it is working,

i still have some adjustemnt to do but it is in a good way, here it is in case you are interested :

include this at the beginning : HedgewarsScriptLoad("/Scripts/Utils.lua")

and then include this :

function onGameTick20()

if CurrentHedgehog ~= nil then
dx, dy = GetGearVelocity(CurrentHedgehog)
if (gearIsInBox(CurrentHedgehog, 1, 1, 4000, 2000)) then
SetGearVelocity(CurrentHedgehog, dx*2, dy*2) --ultra speed ! careful !
end
end
end

edit : result : http://i.imgur.com/o3x7Wvy.gifv


Oh... Grateful, its solved ^_^

I Have workin' on it for roughly 3-4 Hours (+more ?) yesterday
And have (almost) complete (at least) of your Great Idea Big Grin !!!
[ Sleep Time : 2.30 - 3.00 AM ]

I Create a Function :
Accelzone(mode, AccelZoneID, x, y, circle, zoneradius, w, h, accelfollow, xacceleration, yacceleration, xpercentaccel, ypercentaccel, unlimitedstock, speedingstock, interval, effectvgt, opacity1, opacity2, frame, radius, tick, colour)

Which allow me to create Virtual Zone which can come in Square Area or Circle Area, Complete with its Radius...
We can customize how it will work.
How
Its visual gear as effect, colour, etc of its properties
Its Accelerating Power in Direct Number or in Percent, its Following angel, etc
Its also let us to "Limit" and "How" the hog effected will receive the effect, either its have boosting limit, or not, and its also compiled with Interval Rules, where a hog CAN ONLY Receive Speedup in every timer we set...
And some little more things inside
PS : Not just created, but can be Modified as well (use mode)

Even it still WIP
I See its worth it Smile)
So, i think this Library, even wasn't used at all, still worthy to keep and continue :DDD

EDIT : [

To Sphrix :

If wanna write codes like you do for codes from nemo's help above...
You can use "[code*]" to open and "[/code*]" -Without Quotes ("") and Without * (For Example Purpose Only) to close the Codes Text Formatting in forum...

* Example :

Example allegedly wrote:

[code*]function Accelzone(mode, AccelZoneID, x, y, circle, zoneradius, w, h, accelfollow, xacceleration, yacceleration, xpercentaccel, ypercentaccel, unlimitedstock, speedingstock, interval, effectvgt, opacity1, opacity2, frame, radius, tick, colour)
if (player ~= nil) then
if (gearIsInBox(player, 0, 0, 4000, 2048) then
SetGearVelocity(player, 150, 150)
end
end[/code*] <- *To show how it was written

which showing :

Without"*"Example allegedly wrote:

function Accelzone(mode, AccelZoneID, x, y, circle, zoneradius, w, h, accelfollow, xacceleration, yacceleration, xpercentaccel, ypercentaccel, unlimitedstock, speedingstock, interval, effectvgt, opacity1, opacity2, frame, radius, tick, colour)
   if (player ~= nil) then
      if (gearIsInBox(player, 0, 0, 4000, 2048) then
   SetGearVelocity(player, 150, 150)
   end
end

PS : Not trying to be something better, i just share. Nothing More Smile)
Ok then, I hope that would help for future things ^^

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

sphrix
sphrix's picture
User offline. Last seen 1 day 6 hours ago. Offline
Joined: 2011-04-07
Posts: 203

Hey !

Awesome man !

And thank for the advice on formatting on forum :p i think i tried to do ^^

So, how does one use your function ? it look awesome, it even draw the zone right ?

I hope you don't give up because it looks really good ! Smile Smile

ps :

Quote:
For the record, I did recommend adding ±10 to dx for a speed booster, not doubling speed every 20ms ☺

Nemo doesnt want to be held for responsible in case hedgehogs are thrown too fast into wall, he doesnt want to hurt them ! :p

the beachs hogs surfin hedgewars

sphrix
sphrix's picture
User offline. Last seen 1 day 6 hours ago. Offline
Joined: 2011-04-07
Posts: 203

so :

https://www.youtube.com/watch?v=dNp3E8zLL8I

Small video showing the acceleration zone and a visual zone to show where it is (note, the bright red cicle is not corresponding to the pink dot on the map, i should have deleted this dot and adjust the zone but...)

edit thank to : TheAnachron and to UltiMaxKom !

the beachs hogs surfin hedgewars

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]