Closed Lexx2k closed 7 years ago
but it's not possible to check for how much fuel the vehicle currently has
There is the same function :)
gas_amount := call_offset_r0(0x4C4E74);
Don't listen to those hackers, they will teach you bad habits :)
The ideas you talk about are exciting. I think I didn't thought about the idea of having multiple vehicle in the game for a long time. This is however involves more questions to solve:
There is another problem with refueling cars. Example:
if (obj_pid(obj_being_used_with) == PID_MICRO_FUSION_CELL) then begin remove_pid_qty(dude_obj, PID_MICRO_FUSION_CELL, 1) car_give_gas(40000); end
This works. 1 stack of PID_MICRO_FUSION_CELL is removed and the car gets refueled by 40.000 points. Thing is.... the player can actually have less than 1 full stack of said item in his inventory. In case of the MFCs, a (vanilla) stack has 50 charges-- if you fire a plasma rifle, you reduce it. So if the stack now has 40 charges, the above posted script would still work... but now you've refueled 40.000 points with a 40 instead of 50 charge stack. I don't know of any script command to check for this (so one can reduce the 40k points on the fly). The only other solution I see is adding a check "if MFC < 1 stack then deny refuel", but to be honest, this sucks.
Why is this a problem? You can use get_weapon_ammo_count
function for ammo stack (this is just badly named function for getting item charges, also works for Geiger counter, etc.).
I think I have a procedure somewhere that can get and set the precise amount of ammo for given critter and PID. Check out the source code for my EcCo mod.
Huh, I didn't even know that one exists. Can't find it in any of my files / sfall folder. Did a quick search and found it now in gl_highlighting.ssl -- is that a new function?
No, it was added by timeslip a long time ago. Also see my previous comment :)
Don't listen to those hackers, they will teach you bad habits
No. I'll teach you to use what does not yet support sfall.
FuncX(get_gas_amount) {
return call 0x4C4E74;
}
I think it will be so))
Controlling in-game vehicle PID (well, maybe we can just change the art via available scripting function, and in car script check for the current type of "car" and show different descriptions)
This is easily scripted. At the end of the day, the car itself is just a generic scenery object with a script attached that gets created & deleted depending on where the vehicle currently is (car_current_town). The car creation & destruction is defined in scenepid.h, the actual car creation code is in every map script (this is the painful part. Maybe this could be moved to a global script or map enter hook or something.) The car trunk is actually a companion that follows the player around (lel). Explains the old "mysteriously following trunk"-bug from back in the days. It was a fuckup in the "hide trunk if.."-code, which gave players an always accessible, teleporting container. :>
Car startup sound
Same as above, is in zsdrvcar.ssl defined, the script that is attached to the vehicle scenery object.
Something else probably
Biggest issue would be to exchange the car frm file on the worldmap interface, I think. Also we somehow have to define which car is the active one, so not all cars are moving to the same locations, etc. Maybe this can be workarounded with some simple GVARs, I dunno. Also it is necessary to make cars not just look different, but also feel different: Speed, fuel consumption, encounter chance(?), etc. (the Vertibird in the RP could be transformed into a real vehicle, for example)
And yeah, last but not least-- that above mentioned "get amount of current fuel" :p
Interestingly, is it possible to change the picture for the auto (wmcarmve.frm) directly in the game from the script with the write_int () function? And change the value of the index of the picture to another? :-)
Udp: write_int(0x4C2D9B, new_index_frm) - only change index for FRM image, does not work.
@Lexx2k : Did you know that car_give_gas
function returns exact amount of fuel that was not used?
Example you have 50k/80k of gas. If you call car_give_gas(40000)
it will return 10000
, which you can use and subtract the correct amount of ammo from your fusion cell pack.
Edit: this function can also subtract the amount of fuel, but it has no lower boundary check. So you should take care not to end up with a negative amount of fuel :)
I will still add car_current_gas function of course.
Added function. Now about car behavior on world map - it's all in wmWorldMap
function. The question is how to make a useful hook out of this?
The easiest solution is to add hook for wmCarUseGas
, but it will only cover fuel consumption. In order to change car speed need to hook a part of wmWorldMap
function which is not trivial.
Car speed is basically determined by how many times certain function is called every frame (this function is moving party on the map by some fixed distance). And there are checks for car upgrade GVARs that increase speed this way.
Suggestions? I can add 2 hooks:
car_give_gas
with negative value inside and set_sfall_return
to prevent original calculationset_sfall_return
car speed override as an integer. Then I will call the mentioned step function the given number of times, thus effectively simulating dynamic car speed. BUT it won't be possible to set speed to 0 (slower than walk).@FakelsHub:
write_int(0x4C2D9B, new_index_frm) - only change index for FRM image, does not work.
What value did you passed to it? This offset accepts only LST index of the FRM.
Edit: I tested and this approach does work: write_int(0x4C2D9B, 306);
Suggestions? Just add set_car_intface_art
function? Will have to reset the value after on mod reset.
Использовал индекс 535 продублировав фрм, и при выходе на глобальную карту(используя авто) не выходило на нее - гг оставался бегать как бы на лок.карте затирая ее черным фоном :-) Upd: Да точно работает, это я по запарке переименовал frm с 9 буквами в его имени. :)
Let's wait for suggestions from @Lexx2k (as he probably the only one who will ever use this, given how fallout modding is "popular" nowadays :D ) and then we can start making car shops and long awaited motorcycle for FO2 :)
(я джва года.. нет, больше, ждал такой фичи, почему-то в детстве считал что в игре можно раздобыть мотоцикл :) )
There is also Mutants Rising that has a chance to take it in. Also maybe MIBs Mega Mod or maybe we actually do get another RP update some day. :>
I didn't know "car_give_gas" returns a value. How exactly do I fetch that? (remember, I am a shit scripter) If it works and we can calculate fuel with it, we would "just" have to make a macro for it and everyone can use it anyway without having to write their own code all the time, no?
"set_car_intface_art(x)" sounds good and I think that'd be totally fine. I'm not sure about the wmCarUseGas hook stuff, but I don't think it is the end of the world to have a vehicle always be at least as fast as walk speed.
How exactly do I fetch that?
You don't need to do anything fancy. car_give_gas
is a macro for metarule
vanilla opcode which returns integer. Just use it like any function.
со сменой транспортного средства все не так радужно как кажется, особенно с car_current_town одновременно 2 разных транспорта не получится иметь, потому как нет функции set_car_town.
потому как нет функции set_car_current_town.
Как это нет? На месте вроде функция.
Просто при смене транспорта надо будет скриптами запоминать где оставили предыдущий и все.
Как это нет? На месте вроде функция.
А это sfall function - я че то забыл про нее.
0x81b6 - void set_car_current_town(int town)
RTFM :)
@Lexx2k : Added set_car_intface_art
function as well as new hook script. Please review and tell if there is anything missing for car customization.
How exactly do I use it? Just e.g. "set_car_intface_art(123)" ? I've updated my .h files and I can compile, but ingame nothing happens. Is a new dll file required as well? Keep in mind, I'm not a programmer, I don't know shit. :> PS: I'm also too stupid to get the current amount of gas. Whatever I try, it's always 0, so I'm pretty sure I do something very wrong.
Yes of course you need to recompile sfall DLL from latest develop. Or grab this build: https://yadi.sk/d/ri3ZD50L3H2ZmU
Thanks! I was just running some tests and everything appears to work perfect. I can refuel the vehicle correctly now (without wasting ammo charges), and I can apply a custom worldmap icon.
I'm closing the issue as all planned work is done. Until something is reported not working or not properly customizable.
Right now we only have:
It would be good to be able to fetch things like remaining fuel, as well as being able to add new vehicle interface graphics (wmcarmve.frm) without replacing the original.
Refueling the car appears to be hardcoded right now (items for refuel + amount they refuel). This can be workarounded via a custom script and "car_give_gas(x)", but it's not possible to check for how much fuel the vehicle currently has, which can result in the player using up fuel items on a 100% filled car without any effect.
Also interesting would be things like speed of the vehicle (it is modified via ingame "upgrades" right now -- "set_car_upgrade_fuel_cell_regulator" for example), as well as fuel consumption. This way we could add multiple (different) vehicles to the game with a little bit of additional scripting.