I think I got "build-with-one-hammer-hit" version working, too. I think it's even better than the previous one. It also needs one additional script key to work. Hitting a buildsite with hammer starts a timer loop. The loop keeps building until it is finished or the user interrupts by hitting cancelbuild-key.
In game.inf, look for lines like these
- scriptkey=0,Steigen
- scriptkey=1,Sinken
- scriptkey=2,Sprinten
- scriptkey=3,Spezialtaste 1
-
In my case, the first free key was scriptkey 4, yours might be different.
replace "Freie Taste" with:
Now, hitting key 4 launches fk_hit02 (nothing to edit here, just see which number the event gets)
- on:keyhit04 { event "fk_hit02","global"; }
-
So, I declare fk_hit02 (paste after the on:keyrelease11)
- on:fk_hit02 {
- $cancelbuild=1;
- }
-
Now the game setup->keys(2) should have a key for "Cancelbuild".
Remember to configure it! Next, open objects_buildings.inf and replace the script part for buildingsites.
- script=start
- local $hasbeenhit,$howmanymsecleft;
- on:start { if (count("object",500)>0) { skip; }
- if ($building>0) {
- addstate "self",52;
- statesize "self",52,$building;
- }
- }
-
- on:use {
- exchange "self";
- }
-
- on:hit {
- if (getplayerweapon()==30){
- //msg "Klicke mit der rechten Maustaste,",3;
- //msg "um hier zu bauen!",3;
- $cancelbuild=0;
- if($hasbeenhit==0) {
- $hasbeenhit=1;
- $buildhit=impact_id();
- $buildparts= count_stored("object", $buildhit);
- if($buildparts==0) {
- $hasbeenhit=0;
- }
- // 30s/50items=0.6s/item
- $howmanymsecleft=$buildparts*600;
- }
- if($howmanymsecleft<=0) {
- if($hasbeenhit==0) {
- msg "Put the raw materials in first!";
- }
- else {
- msg "Finish the building",3;
- msg "with the right mousebutton!",3;
- }
- }
- else {
- play "build.wav";
- process "Building $howmanymsecleft",1000;
- timer "self",1000;
- }
- }
- }
-
-
-
- on:timer {
-
- if($cancelbuild==0) {
- if($howmanymsecleft<=0) {
- msg "Finish building With right click";
- }
- elseif ($howmanymsecleft<=1000) {
- timer "self",$howmanymsecleft;
- play "build.wav";
- process "building",$howmanymsecleft;
- $howmanymsecleft=0;
- }
- else {
- $howmanymsecleft-=1000;
- play "build.wav";
- process "Building $howmanymsecleft",1000;
- timer "self",1000;
- }
- }
- else {
- msg "Build interrupted!";
- }
- }
- script=end
-
This does not build any faster, but with a lot less clicking! :hooray:
edit: added sound effects