
rerout343
Joined: Aug 7, 2010
Targeted and Firing
|
Posted: Dec 5, 2010 08:20 PM
Msg. 1 of 5
I am working on a script for a device that reacts differently for each weapon on the map. The device works fine but there are two things I would like to add but I'm not sure about what to use for the commands/syntax.
1. The weapon used in the script will be removed from the players inventory. (Maybe "unit_has_weapon assault rifle 0" ?) 2. The script will end after one of the conditions is met and won't check for other weapons.
Here is the script I have so far:
(global object_definition p "weapons\magnum\magnum") (global object_definition ar "weapons\assault rifle\assault rifle") (global object_definition sg "weapons\shotgun\shotgun") (global object_definition ne "weapons\needler\needler") (global object_definition ft "weapons\flamethrower\flamethrower") (global object_definition nr "weapons\impaler\impaler") (global object_definition hr "weapons\heavy_rifle\heavy_rifle") (script continuous pap (sleep_until (= (device_get_position control_pap) 1)) (device_set_power control_pap 0) (if (= (unit_has_weapon_readied (unit (list_get (players) 0)) p) 1) (object_create pap_p)) (if (= (unit_has_weapon_readied (unit (list_get (players) 0)) ar) 1) (object_create pap_ar)) (if (= (unit_has_weapon_readied (unit (list_get (players) 0)) sg) 1) (object_create pap_sg)) (if (= (unit_has_weapon_readied (unit (list_get (players) 0)) ne) 1) (object_create pap_ne)) (if (= (unit_has_weapon_readied (unit (list_get (players) 0)) ft) 1) (object_create pap_ft)) (if (= (unit_has_weapon_readied (unit (list_get (players) 0)) nr) 1) (object_create pap_nr)) (if (= (unit_has_weapon_readied (unit (list_get (players) 0)) hr) 1) (object_create pap_hr)) (sleep 500) (device_set_position control_pap 0) (device_set_power control_pap 1) )
|
|
|

Polamee
Joined: Feb 25, 2008
MP2SPMT's founder
|
Posted: Dec 5, 2010 11:33 PM
Msg. 2 of 5
1.(player_add_equipment [player unit] [starting profile] 1)
So far, its the only way I know to get change the player's current weapons. This will reset the player's health, weapons and shields to the named starting profile.
2. This is an interesting question. I guess you should create a boolean that turns itself on after a weapon has been detected in the player's hands, and the other scripts cannot run without that boolean.
So, you separate each of the unit_has_weapon_readied commands into individual scripts or brackets, then you have it detect if the boolean is true to continue. If the boolean is true, then it will remove the item from the player's inventory. If it is false, the script shall not do anything. Remember that after the end of every command, the script must set the boolean to false.
|
|
|

FtDSpartn
Joined: May 1, 2009
Verified AI.
|
Posted: Dec 6, 2010 12:02 AM
Msg. 3 of 5
pap = Pack a Punch?
;)
|
|
|

Muscl3r
Joined: May 22, 2010
dont pray 4 easy lives...pray to be STRONGER MEN
|
Posted: Dec 6, 2010 02:19 AM
Msg. 4 of 5
Quote: --- Original message by: FtDSpartn pap = Pack a Punch?
;) no, piss a peanut
|
|
|

rerout343
Joined: Aug 7, 2010
Targeted and Firing
|
Posted: Dec 6, 2010 07:33 AM
Msg. 5 of 5
Quote: --- Original message by: FtDSpartn pap = Pack a Punch?
;) Possibly.....I was wondering if anyone would figure that out. But I will try Polamee's method for fixing this. Edited by rerout343 on Dec 6, 2010 at 07:38 AM
|
|
|