Results 1 to 30 of 34

Thread: Challenge for all modders out there

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #26
    Simulation Monkey Member The_Mark's Avatar
    Join Date
    Dec 2004
    Location
    Helsinki, Finland
    Posts
    2,613

    Default Re: Challenge for all modders out there

    Mkay.. I bBegan to do a proper battle script, for a battle like the one described by Duke. Currently the script is a follows:

    Code:
    ;###############  init  #####################################
    	prepare_for_battle
    
    ;*************
    ;player
    ;*************
    
    	label_unit 0 0 0	plr_general
    	label_unit 0 0 1	plr_inf1
    	label_unit 0 0 2	plr_inf2
    	label_unit 0 0 3	plr_inf3
    	label_unit 0 0 4	plr_inf4
    	label_unit 0 0 5	plr_inf5
    	label_unit 0 0 6	plr_inf6
    	label_unit 0 0 7	plr_miss1
    	label_unit 0 0 8	plr_miss2
    	label_unit 0 0 9	plr_inf7
    	label_unit 0 0 10	plr_inf8
    	label_unit 0 0 11	plr_inf9
    	label_unit 0 0 12	plr_inf10
    	label_unit 0 0 13	plr_inf11
    	label_unit 0 0 14	plr_inf12
    
    	define_unit_group plr_army plr_general plr_inf1 plr_inf2 plr_inf3 plr_inf4 plr_inf5 plr_inf6 plr_inf7 plr_inf8 plr_inf9 plr_inf10 plr_inf11 plr_inf112 plr_miss1 plr_miss2
    	define_unit_group plr_front plr_inf1 plr_inf2 plr_inf3 plr_inf4 plr_inf5 plr_inf6
    	define_unit_group plr_missiles plr_miss1 plr_miss2
    	define_unit_group plr_reserves plr_inf7 plr_inf8 plr_inf9 plr_inf10
    
    
    ;*************
    ;AI
    ;*************
    
    	label_unit 1 0 0	AI_general
    	label_unit 1 0 1	AI_leg13
    	label_unit 1 0 2	AI_leg21
    	label_unit 1 0 3	AI_leg22
    	label_unit 1 0 4	AI_leg33
    	label_unit 1 0 5	AI_leg23
    	label_unit 1 0 6	AI_leg12
    	label_unit 1 0 7	AI_leg31
    	label_unit 1 0 8	AI_leg32
    	label_unit 1 0 9 	AI_leg11
    	label_unit 1 0 10	AI_leg_1
    	label_unit 1 0 11	AI_rcav
    	label_unit 1 0 12	AI_lcav
    	label_unit 1 0 13	AI_vel1
    	label_unit 1 0 14	AI_vel2
    	label_unit 1 0 15	AI_vel3
    	label_unit 1 0 16 	AI_raux
    	label_unit 1 0 17	AI_laux
    
    	define_unit_group AI_ARMY AI_general AI_leg13 AI_leg21 AI_leg22 AI_leg33 AI_leg23 AI_leg12 AI_leg31 AI_leg32 AI_leg11 AI_leg_1 AI_rcav AI_lcav AI_raux AI_laux AI_vel1 
    
    AI_vel2 AI_vel3
    
    	define_unit_group AI_1line AI_leg11 AI_leg12 AI_leg13
    
    	define_unit_group AI_2line AI_leg21 AI_leg22 AI_leg23
    
    	define_unit_group AI_3line AI_leg31 AI_leg32 AI_leg33
    
    	define_unit_group AI_skirm AI_vel1 AI_vel2 AI_vel3
    
    			
    ;*************  Locations
    
    	label_location plr_center -590 -134
    	label_location AI_prepline -500 -134
    	label_location veliteloc -550 -134
    	
    ;************* Declaring variables
    
    declare_counter battlephase	; phase 0=deployment/march, 1=missile duel/skirmishing, 2=closing lines, 3=all-out attack 4=monitor situation
    declare_counter skirmphase	; phase	0=closing into range, 1=shooting/throwing part, 2=disengaging skirmishers
    set_counter skirmphase 0
    
    ;**********************
    ; start
    ;**********************
    
    	while ! I_BattleStarted		;standard wait part
    	end_while
    
    	ai_active_set off		;disable core AI in favor of scripted one
    
    	unit_set_skirmish_mode AI_vel1 off
    	unit_set_skirmish_mode AI_vel2 off
    	unit_set_skirmish_mode AI_vel3 off
    
    	battle_wait 4
    	unit_group_order_move_formed AI_ARMY -480 -134 run; march AI army to positons
    	unit_group_order_move_unformed AI_skirm -500 -134 run
    
    	battle_wait 10
    
    	while I_IsUnitGroupMoving AI_ARMY	;wait until army is in position
    	end_while
    
    	battle_wait 10
    	set_counter battlephase 1
    	unit_set_experience plr_general 1 ;debug nodes, watch for general's exp
    
    	while I_InBattle		; main battle loop
    ;**********************************
    ;	== skirmish part ==
    	if battlephase = 1
    		if skirmphase = 0	;skirmish phase 0: skirmishers move to range, loosen formation
    ;		unit_group_change_unit_formation AI_skirm square_hollow
    		unit_group_order_move_unformed AI_skirm -560 -134 run
    		set_counter skirmphase 1
    		unit_set_experience plr_general 2
    		end_if
    ; more to come
    ;		
    	end_if
    ;**********************************
    ; much more to come
    	end_while
    	end_script
    Script layout plan:
    [CODE]init & labels

    defining monitors?

    move AI army to range

    while-loop, checks everything possible implemented in script
    {
    skirmish-part
    {
    {
    move to range, fire next phase when rdy
    }
    {
    shootout, check for possible threats, fire next phase when out of ammo/large casualties to skirmishers
    }
    {
    disengaging, fire next phase when rdy
    }
    }
    main battle part
    {
    {
    close to precursor range (fire at will), position flank guards according to player's flanks, make flanking movements
    }
    {
    charge
    }
    }
    battle checks
    {
    {
    check front line, assign reserves
    }
    {
    check flanking attempts, assign reserves
    }
    {
    after a delay start to check for free reserves, possibly send them to flank
    }
    }
    possibly a delay to lessen CPU load
    end_while
    /CODE]

    Current problems:
    1) The skirmishers don't respond to orders (in skirmish part, the first order is acknowledged)
    2) I can't get monitors working. Dunno what it is.

    Flanking checks could be implemented by: check flanking attempts-part checks the distance of player's units from lines placed on AI's flanks and on AI's front. Flank line checks (obviously) check if player's unit is on outflanking course, front line checks if player's unit has advanced far enough for the reserves to counter it.

    About
    Will the game crash if you label unit sixteen when there are only 15 units?
    for example,
    I_BattlePlayerArmyNumberOfMatchingUnits all > 12
    tests if player has over 12 units. One could use this while labeling, assuming that the game doesn't check if-statements beforehand.


    Some observations on scripting:
    *invalid labeling, using invalid label, using location label in some commands that require a location = CTD on execution of command.
    *mistyped command, missing/extra end_* = script doesn't work but battle runs as usual.

    EDIT: Groups within groups don't work. They can be defined but some of them won't respond to commands.
    Last edited by The_Mark; 03-10-2005 at 18:00.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO