Results 1 to 30 of 34

Thread: Challenge for all modders out there

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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

    Yes, good ideas all, but well.. ASSUMING...

    Well, assuming that we could script the battlefield AI, then why couldn't we also script the campaign AI? (well, ignoring the load/save thingys)

    That combined with a mod like EB.. Yeesss... Excellent...

    But about the scripting.. Any scripting references anywhere? It'd make my life much easier..

  2. #2
    Senior Member Senior Member Duke John's Avatar
    Join Date
    May 2003
    Location
    Netherlands
    Posts
    2,917

    Default Re: Challenge for all modders out there

    CA released 2 documents covering all commands, triggers, conditions and events that can be used in historical battle scripts. I cannot find it on my harddisk or where it was posted (I believe somewhere at the .COM boards). Luckily I have printed it out, but that is of little use to you

    About scripting the game, I thought it didn't reload when loading a saved game. Or did someone find a workaround? It keeps resurfacing that people have found a way to make 4 turns in a year, but they keep forgetting that the script doesn't reload. Or do I not know the whole story?

  3. #3
    Shaidar Haran Senior Member SAM Site Champion Myrddraal's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    5,752

    Default Re: Challenge for all modders out there

    The whole story is, that I have finished the four turns a year script, but it needs to be re-launched manually (using a show me how) after every time you load the game. I will polish up the files and post them within the week.

  4. #4
    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

    Thanks Duke, I found them at the com. No need for you to scan them and send them to me

  5. #5
    Senior Member Senior Member Duke John's Avatar
    Join Date
    May 2003
    Location
    Netherlands
    Posts
    2,917

    Default Re: Challenge for all modders out there

    Simple script (a paste and copy will not work unless you have the 2 sets of 2 units) :

    Code:
    script
    
    ; init
    	prepare_for_battle
    
    	label_unit 0 0 0	GAUL_GENERAL
    	label_unit 0 0 1	GAUL_ARCHER1
    
    	label_unit 1 0 0	ROMAN_ARCHER1
    	label_unit 1 0 1	ROMAN_GENERAL
    
    ;BATTLE SCRIPT
    
    	while ! I_BattleStarted			; WAIT FOR DEPLOYMENT
    	end_while
    
    	ai_active_set off
    
    define_unit_group GRP_GAUL_ARMY GAUL_GENERAL GAUL_ARCHER1
    define_unit_group GRP_ROMAN_ARMY ROMAN_GENERAL ROMAN_ARCHER1
    		
    declare_counter COUNTER1
    
    unit_group_move_to_missile_range_of_group GRP_ROMAN_ARMY GRP_GAUL_ARMY
    
    set_counter COUNTER1 1
    
    while COUNTER1 > 0
    	if I_UnitPercentageAmmoLeft ROMAN_ARCHER1 < 70
    		unit_order_attack_unit ROMAN_GENERAL GAUL_GENERAL run
    		set_counter COUNTER1 -1
    	end_if
    end_while
    
    while I_InBattle
    end_while
    
    end_script
    1. It moves the AI army group towards the player until within missile range. NOTE: it seems that the engine checks at the call of the function what the position should be. If the player moves then the army group doesn't seem to move to a new position.

    2. When the ammo of the AI archers is less than 70% it attacks the players general with the AI general.

    I foresee some problems with being unable to changing facing of an AI army towards the players army. But it looks promising.

    I had some problems with typing commands wrong, so either you need to be very carefull or we need to look into making a scripting utility that autospellchecks scripting.

  6. #6
    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

    Heh..

    Code:
    ;******************************************************************************************************************
    ;	Setting up Battle with Script Commands
    ;******************************************************************************************************************
    
    	prepare_for_battle
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;
    ;;;	Label Units & Groups & LOCATIONS
    ;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;*************
    ;juliis
    ;*************
    
    	label_unit 0 0 0	julii_hastati
    	label_unit 0 0 1	julii_general
    
    
    ;*************
    ;brutiis
    ;*************
    
    	label_unit 1 0 0	brutii_archers
    			
    
    ;**********************
    ; start
    ;**********************
    
    	ai_active_set off
    	
    	unit_order_move_to_missile_range brutii_archers julii_hastati run
    		
    	end_script
    You just had it done further..

    And yes, there's a big danger of misspelling, I spelled bruti instead of brutii in the move order line.. instant CTD.. Maybe my previous statements were a bit too optimistic.

    Quote Originally Posted by Duke John
    I foresee some problems with being unable to changing facing of an AI army towards the players army.
    That is a big problem. I was literally stunned by the lack of any commands returning a position/direction.. those would've made this a lot easier. Of course we could jury-rig a solution with trigonometry or something, but it'd be quite awkward to place a multi-line equation in each and every monitor needing them.. This is assuming the script language supports them. At this point I really miss OFP scripts.. the flexibility.. Hell, someone made a runge-kutta-solver-thingy with them!

    Back to the topic. A spell-checker could be useful, but it wouldn't help with misspelled variables/labels resulting in CTD.. A fully-fledged scripting proggy? But then, of course, we could just try to write them..

    Code:
    set_counter COUNTER1 1
    
    while COUNTER1 > 0
    	if I_UnitPercentageAmmoLeft ROMAN_ARCHER1 < 70
    		unit_order_attack_unit ROMAN_GENERAL GAUL_GENERAL run
    		set_counter COUNTER1 -1
    	end_if
    end_while
    Couldn't the counter, while and if- bits be replaced with:
    Code:
    monitor_conditions I_UnitPercentageAmmoLeft ROMAN_ARCHER1 < 70
    Last edited by The_Mark; 03-08-2005 at 21:22.

  7. #7
    aka AggonyAdherbal Member Lord Adherbal's Avatar
    Join Date
    Oct 2004
    Location
    Belgium
    Posts
    1,014

    Default Re: Challenge for all modders out there

    Then we put all our talents together and develop a strategic game on our own. When a battle occurs, a historical battle script is written. Next you load up R:TW and you play the historical battle. Then we need to extract the outcome of the battle (or perhaps just write up the results) and import it back into the strategic game. Thus you have the excellent battle engine of R:TW but with a proper AI and strategic game that can be as challenging as we want.
    that was exactly my idea for a MP campaign game. I would write a program with an MTW style campaigngame, then when a battle occurs it generates a script and the program pauses. The players then fight this battle in RTW via gamespy. After completion the campaignmap program is resumed and it reads the battle results from the battle's logfile (rtw\logfiles\), and the campaigngame continues.

    It will probably be my next project after Chivalry TW (if I can still be arsed to play RTW by then :))
    Member of The Lordz Games Studio:
    A new game development studio focusing on historical RTS games of the sword & musket era
    http://www.thelordzgamesstudio.com

    Member of The Lordz Modding Collective:
    Creators of Napoleonic Total War I & II
    http://www.thelordz.co.uk

  8. #8
    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