Change сondition сommand drop all items. (key F9)

Feel free to ask any question.
We hope that we can help you, as we are a german-speaking community.
Antworten
Abys
Beiträge: 6
Registriert: Fr 18. Sep 2015, 00:18

Change сondition сommand drop all items. (key F9)

Beitrag von Abys »

Hello, I love this game The wiggles.
Something changed in the procedure beamto_world_all.

Code: Alles auswählen

proc beamto_world_all {} {
	foreach item [inv_list this] {
		// zusдtzliches inv_find_obj, weil beamto_world u.U. mehrere Items ablegt (bei Kiepen mit Inhalt z.B.)
		if {[inv_find_obj this $item] >= 0} {
			beamto_world $item [get_roty this]
		}
	}
}

Code: Alles auswählen

proc beamto_world_all {} {
	foreach item [inv_list this] {
		// zusätzliches inv_find_obj, weil beamto_world u.U. mehrere Items ablegt (bei Kiepen mit Inhalt z.B.)
		if {[inv_find_obj this $item] >= 0} {
		
			set objtype  [get_class_type [get_objclass $item]]
			if {!($objtype == "transport"  ||  $objtype == "tool")} {			
				beamto_world $item [get_roty this]
			}
			
		}
	}
}
Use key F9 gnome droped all items, but no droped transport and tool.

P.S. I think it is a bad or good idea, but this game is can't add new key commands.

Update.
Improved code. Drop all items except Reithamster Hoverboard Kettensaege Presslufthammer Kristallstrahl Holzkiepe Grosse_Holzkiepe.

Code: Alles auswählen

if {[inv_find_obj this $item] >= 0} {
			set objclass [get_objclass $item]
			if {[lsearch {Reithamster Hoverboard Kettensaege Presslufthammer Kristallstrahl Holzkiepe Grosse_Holzkiepe} $objclass] == -1} {
				beamto_world $item [get_roty this]
			}			
		}
Benutzeravatar
Arthur
Zwerg
Zwerg
Beiträge: 197
Registriert: So 1. Mai 2011, 16:10

Re: Change сondition сommand drop all items. (key F9)

Beitrag von Arthur »

Nice one! Thank you for sharing.

Have fun
Arthur
Abys
Beiträge: 6
Registriert: Fr 18. Sep 2015, 00:18

Re: Change сondition сommand drop all items. (key F9)

Beitrag von Abys »

Update 2. If have 5 Reithamster, will droped only 4 reithamster.

Code: Alles auswählen

proc beamto_world_all {} {
	set lockclasses [list]
	
	foreach item [inv_list this] {
		// zusдtzliches inv_find_obj, weil beamto_world u.U. mehrere Items ablegt (bei Kiepen mit Inhalt z.B.)
		if {[inv_find_obj this $item] >= 0} {
			set objclass [get_objclass $item]
			set iscanbeam 1
			
			if {[lsearch {Reithamster Hoverboard Kettensaege Presslufthammer Kristallstrahl Holzkiepe Grosse_Holzkiepe} $objclass] > -1} {
				if {[lsearch $lockclasses $objclass] == -1} {
					lappend lockclasses $objclass
					set iscanbeam 0
				}			
			}			

			if {$iscanbeam} {
				print "beam"
				beamto_world $item [get_roty this]
			}
		}
	}
}
Benutzeravatar
cech12
Zwerg
Zwerg
Beiträge: 242
Registriert: Di 9. Jun 2015, 12:18
Kontaktdaten:

Re: Change сondition сommand drop all items. (key F9)

Beitrag von cech12 »

Hey!

I improved your code. Now you can drop all items except of:
  • the best usable weapons (one ballistic weapon, one onehanded weapon, one twohanded weapon, one shield)
  • one Reithamster (or one Hoverboard if is there)
  • one Holzkiepe (or one Grosse_Holzkiepe if is there)
  • one of each tool (Kettensaege, Presslufthammer, Kristallstrahl)
  • one Schubkarren (if activated ;) )

Code: Alles auswählen

proc beamto_world_all {} {
	//weapons
	set ballistItem -1
	set shieldItem -1
	set onehandItem -1
	set twohandItem -1
	set weaponRankingBallist {Buechse PfeilUndBogen Steinschleuder}
	set weaponRankingShield {Trollschild_3 Drachenschuppe Schild_unq_2 Schild_unq_1 Trollschild_2 Kristallschild Schild_3 Metallschild Schild_2 Schild_1 Trollschild_1 Schild}
	set weaponRankingOneHand {Axt_unq_3 Schwert_4 Krumsaebel Axt_3 Streitkolben Schwert Dolch_1 Axt_unq_1 Schwert_1 Axt_1 Dolch_2 Keule}
	set weaponRankingTwoHand {Hellebarde Axt_unq_4 Zauberstab Axt_4 Lichtschwert Schwert_3 Axt_unq_2 Lanze_2 Axt_2 Schwert_2 Streitaxt Lanze_1}
	
	set searchlockclasses [list]
	//add tools
	lappend searchlockclasses Kettensaege Presslufthammer Kristallstrahl
	//add movement items
	lappend searchlockclasses Reithamster Hoverboard
	//add transport items
	lappend searchlockclasses Holzkiepe Grosse_Holzkiepe Schubkarren
	//add weapons
	foreach item $weaponRankingBallist {lappend searchlockclasses $item}
	foreach item $weaponRankingShield {lappend searchlockclasses $item}
	foreach item $weaponRankingOneHand {lappend searchlockclasses $item}
	foreach item $weaponRankingTwoHand {lappend searchlockclasses $item}
	
	set lockclasses [list]
	set rememberItems [list]

	//search and remember items
	foreach item [inv_list this] {
		set objclass [get_objclass $item]
		
		if {[lsearch $searchlockclasses $objclass] > -1} {
			if {[lsearch $lockclasses $objclass] == -1} {
				
				set canAppend 1
				
				//find lower items
				if {[lsearch {Reithamster} $objclass] > -1} {
					//if item is a Reithamster and in inventory is a Hoverboard
					if {[inv_find this Hoverboard]  > -1} {
						set canAppend 0
					}
				} elseif {[lsearch {Holzkiepe} $objclass] > -1} {
					//if item is a Holzkiepe and in inventory is a Grosse_Holzkiepe
					if {[inv_find this Grosse_Holzkiepe]  > -1} {
						set canAppend 0
					}
				} elseif {[lsearch $weaponRankingBallist $objclass]  > -1} {
					set canAppend 0
					set ballistItem [get_better_weapon $weaponRankingBallist $ballistItem $item]
				} elseif {[lsearch $weaponRankingShield $objclass]  > -1} {
					set canAppend 0
					set shieldItem [get_better_weapon $weaponRankingShield $shieldItem $item]
				} elseif {[lsearch $weaponRankingOneHand $objclass]  > -1} {
					set canAppend 0
					set onehandItem [get_better_weapon $weaponRankingOneHand $onehandItem $item]
				} elseif {[lsearch $weaponRankingTwoHand $objclass]  > -1} {
					set canAppend 0
					set twohandItem [get_better_weapon $weaponRankingTwoHand $twohandItem $item]
				}
				
				if {$canAppend} {
					//remember item
					lappend lockclasses $objclass
					lappend rememberItems $item
				}
			}
		}
	}
	
	//remember weapons
	if {$ballistItem > -1} {lappend rememberItems $ballistItem}
	if {$shieldItem > -1} {lappend rememberItems $shieldItem}
	if {$onehandItem > -1} {lappend rememberItems $onehandItem}
	if {$twohandItem > -1} {lappend rememberItems $twohandItem}
	
	//drop all items
	foreach item [inv_list this] {
		if {[inv_find_obj this $item] >= 0} {
			beamto_world $item [get_roty this]
		}
	}
	
	//get all remembered items
	foreach item $rememberItems {
		take_item $item
	}
	
}

proc is_weapon_usable {weapon} {
        set widtrue [get_weapon_id $weapon true]
	set widfalse [get_weapon_id $weapon false]
	set weaponID 0
	if {$widtrue > $widfalse} {set weaponID $widtrue} else {set weaponID $widfalse}
	return [check_weapon_exp this $weaponID]
}

proc get_better_weapon {weaponRanking weap1 weap2} {
	if {$weap1 == -1} {
		set weap1 $weap2
	} elseif {$weap2 == -1} {
		set weap2 $weap1
	}
	
	//check dwarf experience
	set weap1_exp [is_weapon_usable $weap1]
	set weap2_exp [is_weapon_usable $weap2]
	
	if {$weap1_exp && $weap2_exp} {
		//both weapons can be used
		//check witch one is better
		set objclass1 [get_objclass $weap1]
		set objclass2 [get_objclass $weap2]
		
		foreach objclass $weaponRanking {
			if {$objclass == $objclass1} {
				return $weap1
			}
			if {$objclass == $objclass2} {
				return $weap2
			}
		}
	} else {
		//only one can be used
		if {$weap1_exp} {
			return $weap1
		}
		if {$weap2_exp} {
			return $weap2
		}
	}
	// no one can be used
	return -1
}
You only have to overwrite the function beamto_world_all in the file Data/Scripts/classes/zwerg/z_procs.tcl (nearly line 350).

I added this as a mod to the DigglesModManager (Github, Forum (german)).

Have fun! :D
Chris
Abys
Beiträge: 6
Registriert: Fr 18. Sep 2015, 00:18

Re: Change сondition сommand drop all items. (key F9)

Beitrag von Abys »

Hi, nice. But more elseif can slowe perfomance. When have more wiggles.
Benutzeravatar
cech12
Zwerg
Zwerg
Beiträge: 242
Registriert: Di 9. Jun 2015, 12:18
Kontaktdaten:

Re: Change сondition сommand drop all items. (key F9)

Beitrag von cech12 »

Hey Abys!
But this method is called for only one wiggle when you push F9. Why should more elseif slow down the performance when there are more wiggles?
Chris
Abys
Beiträge: 6
Registriert: Fr 18. Sep 2015, 00:18

Re: Change сondition сommand drop all items. (key F9)

Beitrag von Abys »

cech12 hat geschrieben:Hey Abys!
But this method is called for only one wiggle when you push F9. Why should more elseif slow down the performance when there are more wiggles?
Chris
Hi. Yes, think push f9 one times, it's ok.
Offtop: You have other idea this game? And u have account on github, nice, my name user on github: iGilga.
p.s. i have 1 idea maked - button on\off caves generation for dig more big caves.
Benutzeravatar
cech12
Zwerg
Zwerg
Beiträge: 242
Registriert: Di 9. Jun 2015, 12:18
Kontaktdaten:

Re: Change сondition сommand drop all items. (key F9)

Beitrag von cech12 »

Hey!

Thanks for your mod, nice work! I added it to the new release of the DigglesModManager v0.2.5.
If you have other ideas, feel free to add your mods or change the files. :D

Chris
Antworten