Modification of the game - shooting tank

I have long wanted to make the tank in this game was shot.

And finally dispersed laziness did.

How it works: Sit in a tank to select it for control and clicking right-click on the place in front of the tank - will shoot.

The arc of fire from 12 to 60m 20 degrees.

 

The basic code in the file system_events.py

The code in def on_finally_initialized():

 # Create active land region from the exit regions
 _,y1,x1,_ = system.get_region('REGION_EXIT_WEST')
 x2,_,_,y2 = system.get_region('REGION_EXIT_OST')
system.add_region('REGION_LAND',x1,y1,x2,y2)

Will determine where I clicked on the map adds a region starting from the coordinates of the zones output.Without it the following function useless. (code anywhere)

 

The code in def on_region_click( regionname, x, y ):

 if regionname == "REGION_LAND" and system.get_selected_pcs() == [] and system.camera_in_follow_mode():
_x=x/2
_y=y/2
 for v in system.get_vehicles():
 if not objects.is_destroyed(v) and objects.get_attribute(v, "typeid") == "SET_WHEELTANK" and vehicle.get_char_from_seat(v, 0) in the system.get_pcs():
 dist = objects.get_distance_to_position(v, _x, _y)
 if dist < 80 & dist > 12 and abs(abs(objects.get_direction(v)+180)-objects.get_direction_to_position(v,_x,_y)) < 10:
objects.set_attribute(v,"ammo","SET_AMMOPACK_M79_M203")
radius=amount_of_piercing=value_structure=value_organic=0.0
 # TODO: Reduce ammo in inventory
 if objects.has_attribute(v, "ammo"):
 system.start_effect_object(v, "Dummy_muzzleflash", global_defines.fx_explosion)
 sounds.play_3d_sound_object("shot_m_79", v, None, None)
system.start_effect(_x,_y,0.2,_x,_y,0.6,global_defines.fx_explosion_big)
 sounds.play_3d_sound("c4_small_explo", _x, _y, 0.2)
 ammo = objects.get_attribute(v, "ammo")
 if objects.has_attribute(ammo, "schaden_organisch_max") and objects.has_attribute(ammo, "schaden_organisch_min"):
 value_organic = random.randint(objects.get_attribute(ammo, "schaden_organisch_min"), objects.get_attribute(ammo, "schaden_organisch_max"))
 if objects.has_attribute(ammo, "schaden_struktur_max") and objects.has_attribute(ammo, "schaden_struktur_min"):
 value_structure = random.randint(objects.get_attribute(ammo, "schaden_struktur_min"), objects.get_attribute(ammo, "schaden_struktur_max"))
 if objects.has_attribute(ammo, "durchschlag"):
 amount_of_piercing = objects.get_attribute(ammo, "durchschlag")
 if objects.has_attribute(ammo, "wirkungsbereich"):
 radius = objects.get_attribute(ammo, "wirkungsbereich")
 system.hit_objects_in_ambit( vehicle.get_char_from_seat(v, 0), _x, _y, 0.5, radius, amount_of_piercing, 0, value_structure, value_organic )
 print "Tank Fire on (%.3f, %.3f )"%( _x, _y )
else:
 system.add_text("Goal outside the field of fire.")

And performs all deytviya - ability of the shot and the calculation of the sector fire. (code posted at the beginning of the function body)

 

And of course don't forget to replace all unit import on this here(don't remember what added)

import global_defines
from global_defines import Lambda
from global_defines import data
import character
import vehicle
import globaltext
import system
import music
import sounds
import random
import math
import string
import comments
import timerepr
import object_events
import random
import objects
import zone_ambients
import spawnanimals
import helpfile

 

 

NeiroN 28.08.2017 | Comments (17)













Development by Sergey A.Zhukov 2007-2012